Professional Documents
Culture Documents
11 UnixCaseStudy
11 UnixCaseStudy
Case Study I
UNIX (Linux)
9th ed: Ch. 18
10th ed: Ch. 20
Objectives
• To know a little of the history of UNIX from which Linux is derived
• To understand some principles upon which Linux’s design is based
• To examine the Linux process model and lifecycle
• To describe how Linux schedules processes, provides kernel
synchronization, and provides inter-process communication
Components of a Linux system vidual, specialized management tasks. Some system utilities are invoked
just once to initialize and configure some aspect of the system. Others
—known as daemons in UNIX terminology—run permanently, handling
such tasks as responding to incoming network connections, accepting
logon requests from terminals, and updating log files.
• As most UNIX implementations, thereFigure
are18.1three main pieces
illustrates the various components that make up a full Linux
• Most important distinction is betweensystem.
kernelThe and
most the rest distinction
important here is between the kernel and
everything else. All the kernel code executes in the processor’s privileged
• The kernel is responsible for maintaining the important abstractions of the
mode with full access to all the physical resources of the computer. Linux
operating system refers to this privileged mode as kernel mode. Under Linux, no user code is
built into the kernel. Any operating-system-support code that does not need to
• Executes in kernel mode with full access to all the physical resources of the computer
run in kernel mode is placed into the system libraries and runs in user mode.
• All kernel code and data structures share the same single address space
Unlike kernel mode, user mode has access only to a controlled subset of the
system’s resources.
• System libraries define standard functions apps use to interact with
the kernel
system- user
• Implement much OS functionality that management
user
utility compilers
does not need kernel privileges programs
processes
programs
scheduler dispatch
running
exit or termination
• Running/Runnable (R) Zombie
• Process state. The state may be new, ready,
signals
so on.
running, waiting, halted, and
• Interruptible Sleep (S) • CPU registers. The registers vary in number and type, depending on
the computer architecture. They include accumulators, index registers,
stack pointers, and general-purpose registers, plus any condition-code
wait for Running / Runnable
• Stopped (T) resources/ (R)
SIGSTOP
information. Along with the program counter, this state information must
be saved when an interrupt occurs, to allow the process to be continued
correctly afterward (Figure 3.4). received
• Zombie (Z) signals • CPU-scheduling information. This information includes a process priority,
wakeup/ pointers to scheduling queues, and any other scheduling parameters.
SIGCONT
(Chapter 6 describes process scheduling.)
signal wait• for receivedThis information may include such
Memory-management information.
items as the value of the base and limit registers and the page tables, or the
resources
segment tables, depending on the memory system used by the operating
Uninterruptible system (Chapter 8).
Stopped
Sleep (D) wakeup
(T)
process state
Interruptible process number
registers
memory limits
11. UNIX Case Study (I) list of open files 18
Task scheduling
• Allocation of CPU time to different tasks
• As well as processes, in Linux this includes various kernel tasks
• Those requested by a running process and those executed for a device driver
• Traditional UNIX scheduling uses fixed time slices and priorities to
boost/penalise
• Quantum 100ms, round-robin within priority levels
• Priority set from process’ base priority, average length of process’ run queue,
and nice value
• Worked ok for early time-sharing systems but did not scale or provide
good interactive performance for current systems
increasing priority
recursive interrupts disabled bottom-half interrupt handlers
• Bottom half is run, with all
interrupts enabled, by a kernel-system service routines (preemptible)
miniature scheduler that ensures
user-mode programs (preemptible)
bottom halves never self-interrupt
• This architecture is completed by a mechanism for disabling selected
Figure 18.2 Interrupt protection levels.
bottom halves while executing normal, foreground kernel code
bottom halves to prevent any other critical sections from interrupting it. At
the end of the critical section, the kernel can reenable the bottom halves and
run any bottom-half tasks that have been queued by top-half interrupt service
11. UNIX Case Study (I) 22
routines during the critical section.
Inter-Process Communication
• Signals
• Process-to-process
• Limited number, carry no information other than which signal has occurred
• Wait queues
• Used inside the kernel
• Process puts itself on wait queue for an event, and informs scheduler that it is no longer
eligible for execution
• All waiting processes are woken when the event completes
• Pipes
• Just another type of inode in the VFS
• Each pipe has a pair of wait queues for reader and writer to synchronise
• Shared memory
• Fast but no synchronisation mechanism – need to be provided
• Persistent object, like a small independent address space