Context Switch
• Switching the CPU to another process
requires performing a state save of the
current process and a state restore of a
different process.
Context Switch
• is the mechanism to store and restore the
state or context of a CPU in Process Control
block so that a process execution can be
resumed from the same point at a later
time. Using this technique a context
switcher enables multiple processes to
share a single CPU.
Context Switch
Context Switch
• Program Counter
• Scheduling Information
• Base and limit register value
• Currently used register
• Changed State
• I/O State
• Accounting
Operations on Processes
• The processes in most systems can
execute concurrently, and they may be
created and deleted dynamically.
Operations on Processes
Process Creation
• During the course of execution, a
process may create several new
processes. As mentioned earlier, the
creating process is called
a parent process, and the new
processes are called the children of that
process.
Operations on Processes
Operations on Processes
Operations on Processes
two possibilities for execution exist:
• The parent continues to execute
concurrently with its children.
• The parent waits until some or all of its
children have terminated.
Operations on Processes
two address-space possibilities for the
new process:
• The child process is a duplicate of the
parent process (it has the same
program and data as the parent).
• The child process has a new program
loaded into it.
Operations on Processes
Operations on Processes
Process Termination
• A process terminates when it finishes
executing its final statement and asks
the operating system to delete it by
using the exit() system call.
Process Termination
A parent may terminate the execution of
one of its children for a variety of reasons:
• The child has exceeded its usage of
some of the resources that it has been
allocated.
• The task assigned to the child is no
longer required.
Process Termination
A parent may terminate the execution of
one of its children for a variety of reasons:
• the parent is exiting, and the operating
system does not allow a child to
continue if its parent terminates.
Process Termination
We can terminate a process by using the
exit() system call, providing an exit status
as a parameter:
Process Termination
The wait() system call is passed a
parameter that allows the parent to
obtain the exit status of the child.
Process Termination
Zombie Process
• A process that has terminated, but
whose parent has not yet called wait()
THANK YOU
AND
GOD BLESS!