Beruflich Dokumente
Kultur Dokumente
10EC65
Unit 3
Process Management
Reference Book:
Operating Systems - A Concept based Approach
D. M. Dhamdhare, TMH, 3rd Edition, 2010
Shrishail Bhat, AITM Bhatkal
Introduction Process Concept
5.7
Shrishail Bhat, AITM Bhatkal
Example: Child Processes in a Real-Time Application
When an event occurs, the kernel must find the process whose
state is affected by it
OSs use various schemes to speed this up
E.g., Event Control Blocks (ECBs)
Kernel-Level Threads
Threads are managed by the kernel
User-Level Threads
Threads are managed by thread library
Hybrid Threads
Combination of kernel-level and user-level threads
A kernel-level thread is
implemented by the kernel
Creation, termination and
checking their status is
performed through system
calls
Advantages
A kernel-level thread is like a process except that it has a smaller
amount of state information. This similarity is convenient for
programmers
In a multiprocessor system, kernel-level threads provide parallelism
Better computation speed-up
Disadvantages
Switching between threads is performed as a result of event
handling. Hence it incurs the overhead of event handling even if
the interrupted thread and the selected thread belong to the same
process
Advantages
Thread synchronization and scheduling is implemented by the
thread library. So thread switching overhead is smaller than in
kernel-level threads.
This also enables each process to use a scheduling policy that best
suits its nature
Disadvantages
Blocking a thread would block its parents process. In effect, all
threads of the process would get blocked.
User-level threads cannot provide parallelism and concurrency
Shrishail Bhat, AITM Bhatkal
Hybrid Thread Models
Many-to-one association
A single kernel-level thread is created in a process by the kernel and all
user level threads created in a process by the thread library are associated
with this kernel-level thread
Provides an effect similar to mere user-level threads
One-to-one association
Each user-level thread is permanently mapped into a kernel-level thread
Provides an effect similar to mere kernel-level threads
Many-to-many association
Permits a user-level thread to be mapped into different kernel-level
threads at different times
It provides parallelism and low overhead of switching
Shrishail Bhat, AITM Bhatkal
Case Studies of Processes and Threads
Processes in Unix
Threads in Solaris
Data Structures
Unix uses two data structures to hold control data about
processes
proc structure
Holds scheduling related data
Always held in memory
u area (user area)
Holds data related to resource allocation and signal handling
Needs to be in memory only when the process is executing
Types of Processes
User processes
Execute user computations
Associated with the users terminal
Daemon processes
Detached from the users terminal
Run in the background and perform functions on a system-wide basis
Vital in controlling the computational environment of the system
Kernel processes
Execute the code of the kernel
Concerned with background activities of the kernel like swapping
Shrishail Bhat, AITM Bhatkal
Process Creation and Termination
The system call fork creates a child process and sets up its
context
It allocates a proc structure for the newly created process and
marks its state as ready, and also allocates a u area for the
process
The kernel keeps track of the parentchild relationships using
the proc structure
fork returns the id of the child process
The shell process now executes the wait system call to wait for
end of the primary process of the program
Thus it becomes blocked until the program completes, and
becomes active again to accept the next user command
If a shell process performs an exit call to terminate itself, init
creates a new process for the terminal to run the login shell
Race conditions
in cases 2 and 3