Professional Documents
Culture Documents
Operating System Concepts: The Process
Operating System Concepts: The Process
Lecture -3
The Process
A process includes:
Stack : contains temporary data, such as function parameters, return address, local variables
Process State
Waiting: The process is waiting for some event to occur (such as an I/O completion or reception
of a signal)
Schedulers
A process migrates among the various scheduling queues throughout its lifetime.
Scheduler selects processes from different queues.
Long-term scheduler (or job scheduler) selects which processes should be brought into
memory for execution.
Short-term scheduler (or CPU scheduler) selects which process should be executed
next and allocates CPU
- Sometime the only scheduler in the system
Short-term scheduler is invoked very frequently (milliseconds) (must be fast)
Long-term scheduler is invoked very infrequently (seconds, minutes) (may be slow)
Context Switch
When CPU switches one process to another process, the system must save the state of the old process
and load the saved state for the new process via a context switch. When context switch occurs the
kernel saves the context of the old process in its PCB.
Context of a process represented in the PCB
Context-switch time is overhead; the system does no useful work while switching
The more complex the OS and the PCB -> longer the context switch
Time dependent on hardware support
Some hardware provides multiple sets of registers per CPU -> multiple contexts loaded at
once
Process Creation
A process may create several new processes, via a create-process system call, during execution.
The creating process is called parent process.
The new processes are called the children process.
Each process in turn creates other processes, forming a tree of processes.
Generally, process identified and managed via a unique process identifier (pid)
When a process creates a sub process, it also needs resources.
Resource sharing options
Process Termination
A process terminate, when it finishes executing its final statement
It asks the OS for deleting itself by exit() system call
At this point, the process may return the status value to the parent via wait() system call
All the resources used by the child process will be deallocated
Some process may terminate child process by TerminateProcess() system call
A process may terminate the execution of its child process for variety of reason
Child has exceeded allocated resources
Task assigned to child is no longer required
If parent is exiting
Some operating systems do not allow child to continue if its parent terminates
All children terminated - cascading termination
Inter-process Communication
Processes within a system may be independent or cooperating
Cooperating process can affect or be affected by other processes, including sharing data
Reasons for cooperating processes:
Information sharing
Computation speedup
Modularity
Convenience
Two models of IPC
Shared memory
Message passing