Os Unit 1 Part 2
Os Unit 1 Part 2
Process Management
Process Concept- Process Definition,
A Program does nothing unless its instructions are executed by a CPU.
A program in execution is called a process.
Process State
The process, from its creation to completion, passes through various states.
The state of a process is defined in part by the current activity of that process.
Each process may be in one of the following states during execution.
➢ Ready - The process has all the resources available that it needs to run, and waiting to be
assigned to a processor.
➢ Waiting - The process cannot run at the moment, because it is waiting for some resource to
become available or for some event to occur. For example, the process may be waiting for
keyboard input, disk access request.
➢ The running process finished its execution and then it exits and goes to the terminated state.
➢ There can be an interrupt when the process was being executed. When this process was
being executed some other process with high priority comes, then this process was interrupted.
When it gets interrupted, it goes back to the Ready State again. Once the interrupt has been
handled this process again be dispatched and assigned to a processor and it can begin its
execution and go to the running state again.
➢ When the process is running it needs to wait for an input/output operation or an event. At
that time, it goes to the waiting state. Once the input/output operation or the event that it was
waiting for has been completed it goes to the ready state again.
Threads
Threads in Operating System A thread is a single sequential flow of execution of tasks of a
process.
It is a basic unit of CPU utilization.
Components of Thread A thread has the following three components:
1. Program Counter
2. Register Set
3. Stack space
Context Switch
The Context switching is a technique or method used by the operating system to switch a
process from one state to another to execute its function using CPUs in the system.
Operations on Processes- Creation and Termination of Processes
Process Creation
A process may be created in the system for different operations.
Some of the events that lead to process creation are as follows −
Process Termination
Process termination occurs when the process is terminated.
The exit() system call is used by most operating systems for process termination.
Some of the causes of process termination are as follows −
It is one of the region for data communication Mainly the message passing is used for
communication.
It is used for communication between single It is used in distributed environments where the
processor and multiprocessor systems where communicating processes are present on remote
the processes that are to be communicated machines which are connected with the help of a
present on the same machine and they are network.
sharing common address space.
The shared memory code that has to be read or Here no code is required because the message
write the data that should be written explicitly passing facility provides a mechanism for
by the application programmer. communication and synchronization of actions
Shared Memory Message Passing
In shared memory make sure that the processes Message passing is useful for sharing small
are not writing to the same location amounts of data so that conflicts need not occur.
simultaneously.
Given below is the structure of shared memory Given below is the structure of message passing
system − system −