What is Process..? Process is a program in execution. It may contain the current activity represented by the program counter and the content of C.P.U. register. The main diffrence between program and process is that program is user written and process is generated by the operating system to run small part of that program.
The Process States:- New:- The process is being created. Running:- The process is currently running and has control of a C.P.U. Waiting:- The process is currently able to run but must wait until a CPU becomes available.
Ready:- The process is in memory and will assigned to the CPU. Terminated:- The process has finished execution.
Process Control Block [PCB] Operating system executes progrms as diffrent processes. As processes runs it is necessary to keep certain details related to processes. The OS maintain the information about each process in a record is called process control block. Each process its own PCB block is used to track the process execution status.
Process State Process Number Program counter Registers Memory Limits List of open files . . . . Process Control Block
Scheduling levels… Long term scheduling Medium term scheduling Short term scheduling
Long Term Scheduling Long term scheduling pick up a job from the job pool and loads into main memory for execution is called as long term scheduler or job scheduler.
Short Term Scheduling There is another scheduler which selects the job or process which are ready to execute from its pool and allocate them to C.P.U. to one of them is called short term scheduler or CPU scheduler.
Medium Term Scheduling The main purpose of that if removes the process from main memory and again reloads after words when required is called medium term scheduler.
Short Term S. Long Term S. Medium Term S. Frequency of execution is high may be in some milliseconds. Frequency of execution is in few minutes. Frequency of execution is medium. It work fast. It work slow as compare to S.T.S. Are called whenever required. Deals with C.P.U. Deals with main memory for loading process. Deals with main memory for removing process & reloading whenever required D I F F R E N C e
Context Switch Switching to the different processes requires two operations i.e. the one is state save for running process and state restore for another process.This task is referred as a Context Switch.
When CPU switches from one process to another process the system must save the state of the old process and load the saved state for the new process. Switching time is depend on hardware support.
Operations on processes Process Creation Process Termination Process are created by the operating system to simplify the job of execution of the program by the C.P.U.
Fork() System call Wait system call Resumes Parents Exec() System call Exit() System call child Fig. Process Creation
Resource Sharing:- Parent and children may share resources. Children share subset of parents resources. Execution:- Parent and children execute concurrently. Parent wait until children terminate.
Address space:- Child is duplicate of parent. Child may have different programs load into it UNIX example:- Fork system call create new process.
Inter-Process Communication Process executing concurrently in the system may be independent or may be cooperating processes. Independent process cannot affect or do not get affected by the execution of another process
Cooperating process can affect or can get affected by the execution of another process.
A D V A N T a G E S Information Sharing Communication speed-up Modularity Convenience Shared Memory Message passing Types Of inter-process communication
Threads… A thread is a basic unit of C.P.U. utilization. it is alight weight process. A thread is associated w ith thread ID, PC, register set and a stack. Single-threaded process Multi-threaded process
Benefits of multithreaded programming Responsiveness Resource sharing Economy Utilization of multiprocessor architecture
User thread and kernal thread Many to one model One to one model Many to many model
Many to one model Use to library. Efficient system in terms of performance. Advantages:- Disadvantages:- Can not run multiple user threads parallel. One block call blocks all user threads.
One to one model More concurrency. Multiple threads can run parallely. Advantages:- Disadvantages:- Every time user’s & kernal thread is created. Kernal thread is an overhead.
Many to many model Many threads can be created as per user requirement Multiple kernel or equal to user threads can be created Advantages:- Disadvantages:- True concurrency can not be achieved. Performance is less.