UNIX and Linux Internals - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

UNIX and Linux Internals

Description:

Shared characteristics allow applications and users to treat varieties as single ... been published in an attempt to promulgate a standardized way of referring to a ... – PowerPoint PPT presentation

Number of Views:373
Avg rating:3.0/5.0
Slides: 25
Provided by: jomae
Category:

less

Transcript and Presenter's Notes

Title: UNIX and Linux Internals


1
UNIX and Linux Internals
  • Davis and Rajkumar (6th), Chp 13

2
Overview
  • Unix systems
  • Images and processes
  • Boot process
  • Time-slicing and interrupts
  • Memory management
  • File system
  • UNIX internals
  • Linux internals

3
Unix Systems
  • All varieties of Unix share common
    characteristics
  • User interface
  • System calls
  • POSIX
  • Shared characteristics allow applications and
    users to treat varieties as single OS
  • For differences, see www.unixguide.net

4
POSIX
  • Portable Operating System Interface for Unix
  • IEEE standard for application interface with Unix
    operating system
  • Most have names ending in X (e.g. HPUX, AIX, PNX,
    Xenix, etc)
  • The original standard published in 1986
  • Latest revision merges with The Open Group's Base
    Specifications with UNIX
  • Richard Stallman comment on pronouncing POSIX
  • It is expected to be pronounced pahz-icks as in
    positive, not poh-six, or other variations. The
    pronunciation has been published in an attempt to
    promulgate a standardized way of referring to a
    standard operating system interface".

Source http//www.pasc.org/
5
Hardware-dependent Kernel
Applicationprogram
User
Operating system layer
Hardware layer
6
Unix Portability
  • Most operating systems written in assembler
  • Different for each processor family
  • Must be rewritten for each processor family
  • Unix varieties written in C
  • C language doesnt change
  • Code recompiled for each processor
  • Unix is extra-ordinarily portable

7
Images
  • Users routine viewed as image
  • Execution environment (pseudocomputer)
  • Contains program, data storage, content of
    general purpose registers, status of files, and
    current directory
  • Each user has image
  • User sees dedicated command driven VM
  • OS sees multiple images in shared environment

8
Image Segments
  • Image starts at virtual address 0
  • Three segments with free area between data and
    stack segments
  • Data grows toward high memory (stack)
  • Stack grows toward low memory (data)

9
Processes
  • Executing image is a process
  • During execution, segments must be in memory, but
    not contiguous memory
  • Program segment reentrant (public)
  • Only one copy of in memory
  • Several user may use it
  • Data and stack segments privateeach user has own
    copy

10
Process Creation
  • Processes created by fork routine
  • Fork creates copy of parent to form child
  • Parent and child
  • Share system data and open files
  • Have different return code (RC)
  • See, man fork

11
Boot Process
  • Process init activated
  • Creates process for each potential logon
  • Each logon process parent shell for user
  • Usually logon spawns a shell
  • May have no shell and launch application
  • When logon dies, init spawn new logon
  • Run levels
  • 0, 5, and 6 shutdown
  • 1 single user at console
  • 2 multiple users
  • 3 multiple users with network support
  • 4 unused multiple users

12
UNIX Scheduling
  • Dispatcher schedules processes
  • Dispatcher uses process table
  • Process table
  • One entry per process created by fork
  • Entry contains scheduling information
  • Each process has priority
  • Execution time / Elapsed time
  • Smaller number yields higher priority
  • Highest priority process gets next processor time
    slice
  • Solaris scheduling, see man sched

13
Time-slicing and Interrupts
  • Pre-emptive use of processor
  • Process allowed to execute during time-slice
  • Forced to yield processor at end of time-slice
  • Time-slice is small amount of processor time
  • For more information, see man timex
  • When interrupt occurs
  • Interrupt hardware dependent
  • Executing process forced to yield processor
  • Control passes to kernel

14
Summary of Process Management
  • Process is executing image
  • Image is execution environment or pseudocomputer
  • Image consists of program text, data, and stack
    segments
  • fork creates new process by copying parents
    image
  • Processes scheduled based on time since last use
    of processor
  • Pre-emptive scheduling based on time-slices

15
Memory Management
  • Virtual memory and segmentation used
  • Paging (swap)
  • At creation of process, entire image put in
    physical memory
  • As image grows, pages of segments may be put in
    secondary storage (virtual memory)
  • Memory space and reentrant code
  • Several processes can use same program text
    segment
  • Shared text segment must stay in memory

16
File System
  • Key to Unix operating systems
  • All data treated as strings of bytes
  • Block structured devices (usually disks)
  • Ordinary (data) files and special (devices) files
  • Four regions of standard block device (disk)
  • Boot block holds boot routine
  • Super block identifies disk, size of regions,
    free blocks
  • i-list list of i-nodes i-node 64-bytes of
    information about a file (file definition)
  • File and directory blocks actual files and
    directories
  • Character devices include printers and other
    non-block structured devices

17
i-Node
  • i-node stands for index node
  • All types of file administered using i-node
  • One 64-byte i-node entry in i-list for each file
  • i-nodes contains
  • File mode type, execution flags, permissions
  • Link count number of directory references
  • Owner ID UID number of owner
  • Group ID GID number of group
  • File size number of bytes
  • Last accessed Time file last accessed
  • Last modified Time file last modified
  • i-node modified Time this index entry last
    modified
  • Directory makes association between filename and
    i-node number

18
i-Node and Directory Relationship
  • Directory
  • i1 FileName1
  • i2 FileName2
  • i3 FileName3
  • i-List
  • i1 Entry for i1
  • i2 Entry for i2
  • i3 Entry for i3

19
UNIX Kernel Architecture
Libraries
User Programs
User Level
Kernel Level
System Call Interface
File Subsystem
Device drivers
hardware control
Hardware Level
hardware
Source www.cse.ttu.edu.tw/cheng/courses/unix/uni
x23.ppt
20
UNIX System Tables
Physical device
File on disk
Device driver
Texttable
Configurationtable
System filetable
Processtable
Open file list
Text segment
Data segment
System datasegment
Process file table
Stack segment
Workingdirectory
21
Linux Architecture
User process
System libraries
Kernel
System call interface
Architecture dependent code
22
Linux Processes
  • Either fork or clone creates process
  • Process divided into threads
  • Basic unit of work
  • Interruptible
  • Threads
  • Normal
  • Real-time

23
Linux Scheduler
  • Schedules threads based on priorities
  • Each process assigned base priority
  • Each thread goodness value
  • Process base priority for normal threads
  • Process base priority plus 1000 for real-time
    threads
  • Highest goodness valued thread in ready state
    gets processor
  • Execution
  • Real-time before normal threads
  • First-in/first-out real-time threads execute to
    completion
  • Round robin real-time threads get single time
    slice
  • Normal execute for goodness value number of time
    slices

24
Summary
  • Unix varieties usually POSIX compliant
  • Portable Operating System Interface for Unix
  • IEEE standard for application interface with
    operating system
  • Hardware dependent code concentrated in kernel
  • Unix portable operating system recompile rather
    than rewrite
  • Image foundation of process management
  • Virtual memory used by images, which is broken
    into pages for physical memory management
  • File system key to Unix OSprovides common
    treatment of files and devices
  • Linuxs architecture shows advances in structured
    programming
Write a Comment
User Comments (0)
About PowerShow.com