Operating
Systems
Unit 2
PROCESS
• Process is the execution of a program that performs the actions specified in that program. It can be
defined as an execution unit where a program runs.
• The OS helps you to create, schedule, and terminates the processes which is used by CPU. A
process created by the main process is called a child process.
• Process operations can be easily controlled with the help of PCB(Process Control Block).
• You can consider it as the brain of the process, which contains all the crucial information related to
processing like process id, priority, state, CPU registers, etc.
What is Process Management?
• Process management involves various tasks like creation, scheduling, termination of processes,
and a dead lock.
• Process is a program that is under execution, which is an important part of modern-day operating
systems.
• The OS must allocate resources that enable processes to share and exchange information. It also
protects the resources of each process from other methods and allows synchronization among
processes.
• It is the job of OS to manage all the running processes of the system. It handles operations by
performing tasks like process scheduling and such as resource allocation.
•Stack: The Stack stores temporary data like function parameters, returns
addresses, and local variables.
•Heap Allocates memory, which may be processed during its run time.
•Data: It contains the variable.
•Text:
Text Section includes the current activity, which is represented by the
value of the Program Counter.
How does the process look like in
memeory
Attributes or Characteristics of a
Process
A process has the following attributes.
1.Process Id: A unique identifier assigned by the operating system
2.Process State: Can be ready, running, etc.
3.CPU registers: Like the Program Counter (CPU registers must be saved and restored when a
process is swapped in and out of the CPU)
4.Accounts information: Amount of CPU used for process execution, time limits, execution ID, etc
5.I/O status information: For example, devices allocated to the process, open files, etc
6.CPU scheduling information: For example, Priority (Different processes may have different
priorities, for example, a shorter process assigned high priority in the shortest job first scheduling)
.
States of Process
1. New: Newly Created Process (or) being-created process.
2. Ready: After the creation process moves to the Ready state, i.e. the process is ready for execution.
3. Run: Currently running process in CPU (only one process at a time can be under execution in a
single processor)
4. Wait (or Block): When a process requests I/O access.
5. Complete (or Terminated): The process completed its execution.
6. Suspended Ready: When the ready queue becomes full, some processes are moved to a
suspended ready state
7. Suspended Block: When the waiting queue becomes full.
Process Control Block
• With the creation of a process, a PCB is created which controls how that process is being carried
out.
• The PCB is created with the aim of helping the OS to manage the enormous amounts of tasks that
are being carried out in the system.
• PCB is helpful in doing that as it helps the OS to actively monitor the process and redirect system
resources to each process accordingly.
• The OS creates a PCB for every process which is created, and it contains all the important
information about the process. All this information is afterward used by the OS to manage
processes and run them efficiently.
Process Control Block
Process Control Block
• Process State: The state of the process is stored in the PCB which helps to manage the processes and
schedule them. There are different states for a process which are “running,” “waiting,” “ready,” or “terminated.”
• Process ID: The OS assigns a unique identifier to every process as soon as it is created which is known as
Process ID, this helps to distinguish between processes.
• Program Counter: While running processes when the context switch occurs the last instruction to be executed
is stored in the program counter which helps in resuming the execution of the process from where it left off.
• CPU Registers: The CPU registers of the process helps to restore the state of the process so the PCB stores a
copy of them.
• Memory Information: The information like the base address or total memory allocated to a process is stored in
PCB which helps in efficient memory allocation to the processes.
• Process Scheduling Information: The priority of the processes or the algorithm of scheduling is stored in the
PCB to help in making scheduling decisions of the OS.
• Accounting Information: The information such as CPU time, memory usage, etc helps the OS to monitor the
performance of the process.
Operations that are Carried out with the help of PCB
• Process Scheduling: The different information like Process priority, process state, and resources
used can be used by the OS to schedule the process on the execution stack. The scheduler checks
the priority and other information to set when the process will be executed.
• Multitasking: Resource allocation, process scheduling, and process synchronization altogether
helps the OS to multitask and run different processes simultaneously.
• Context Switching: When context switching happens in the OS the process state is saved in the
CPU register and a copy of it is stored in the PCB. When the CPU switches to another process and
then switches back to that process the CPU fetches that value from the PCB and restores the
previous state of the process.
• Resources Sharing: The PCB stores information like the resources that a process is using, such
as files open and memory allocated. This information helps the OS to let a new process use the
resources which are being used by any other process to execute sharing of the resources.
Independent and Cooperating Processes
• Independent Process: Independent Processes are those processes whose task is not dependent
on any other processes.
• Cooperating Process: Cooperating Processes are those processes that depend on other
processes or processes. They work together to achieve a common task in an operating system.
These processes interact with each other by sharing the resources such as CPU, memory, and I/O
devices to complete the task.
Inter Process Communication (IPC)
• Inter process communication (IPC) is used for exchanging data between multiple threads in one
or more processes or programs. The Processes may be running on single or multiple computers
connected by a network. The full form of IPC is Inter-process communication.
• It is a set of programming interface which allow a programmer to coordinate activities among
various program processes which can run concurrently in an operating system. This allows a
specific program to handle many user requests at the same time.
• Since every single user request may result in multiple processes running in the operating system,
the process may require to communicate with each other. Each IPC protocol approach has its own
advantage and limitation, so it is not unusual for a single program to use all of the IPC methods.
Role of Synchronization in Inter Process Communication
• Inter process communication (IPC) is used for exchanging data between multiple threads in one
or more processes or programs. The Processes may be running on single or multiple computers
connected by a network. The full form of IPC is Inter-process communication.
• It is a set of programming interface which allow a programmer to coordinate activities among
various program processes which can run concurrently in an operating system. This allows a
specific program to handle many user requests at the same time.
• Since every single user request may result in multiple processes running in the operating system,
the process may require to communicate with each other. Each IPC protocol approach has its own
advantage and limitation, so it is not unusual for a single program to use all of the IPC methods.
Role of Synchronization in Inter Process Communication
• It is one of the essential parts of inter process communication. Typically, this is provided by
interprocess communication control mechanisms, but sometimes it can also be controlled by
communication processes.
• These are the following methods that used to provide the synchronization:
1. Mutual Exclusion
2. Semaphore
3. Barrier
4. Spinlock
Role of Synchronization in Inter Process Communication
Mutual Exclusion:-
•It is generally required that only one process thread can enter the critical section at a time. This also
helps in synchronization and creates a stable state to avoid the race condition.
Semaphore:-
•Semaphore is a type of variable that usually controls the access to the shared resources by several
processes. Semaphore is further divided into two types which are as follows:
1.Binary Semaphore
2.Counting Semaphore
Role of Synchronization in Inter Process Communication
Barrier:-
•A barrier typically not allows an individual process to proceed unless all the processes does not
reach it. It is used by many parallel languages, and collective routines impose barriers.
•Spinlock:-
•Spinlock is a type of lock as its name implies. The processes are trying to acquire the spinlock waits
or stays in a loop while checking that the lock is available or not. It is known as busy waiting because
even though the process active, the process does not perform any functional operation (or task).
Approaches to Interprocess Communication
Barrier:-
•A barrier typically not allows an individual process to proceed unless all the processes does not
reach it. It is used by many parallel languages, and collective routines impose barriers.
•Spinlock:-
•Spinlock is a type of lock as its name implies. The processes are trying to acquire the spinlock waits
or stays in a loop while checking that the lock is available or not. It is known as busy waiting because
even though the process active, the process does not perform any functional operation (or task).
Approaches to Interprocess Communication
Process Scheduling
• The process scheduling is the activity of the process manager that handles the removal of the
running process from the CPU and the selection of another process on the basis of a particular
strategy.
• Process scheduling is an essential part of a Multiprogramming operating systems. Such operating
systems allow more than one process to be loaded into the executable memory at a time and the
loaded process shares the CPU using time multiplexing.
• Process scheduling is the activity of the process manager that handles the removal of the running
process from the CPU and the selection of another process on the basis of a particular strategy.
• Process scheduling is an essential part of a Multiprogramming operating system. Such operating
systems allow more than one process to be loaded into the executable memory at a time and the
loaded process shares the CPU using time multiplexing.
Process Scheduling Queues
• The OS maintains all Process Control Blocks (PCBs) in Process Scheduling Queues. The OS maintains a
separate queue for each of the process states and PCBs of all processes in the same execution state are
placed in the same queue. When the state of a process is changed, its PCB is unlinked from its current queue
and moved to its new state queue.
• The Operating System maintains the following important process scheduling queues −
• Job queue − This queue keeps all the processes in the system.
• Ready queue − This queue keeps a set of all processes residing in main memory, ready and waiting to execute.
A new process is always put in this queue.
• Device queues − The processes which are blocked due to unavailability of an I/O device constitute this queue.
Types Of Schedulers
• Long term Schedulers
• Short term Schedulers
• Medium term Schedulers
Long term Schedulers
• Long term scheduler is also known as job scheduler. It chooses the processes from the pool
(secondary memory) and keeps them in the ready queue maintained in the primary memory.
• Long Term scheduler mainly controls the degree of Multiprogramming. The purpose of long term
scheduler is to choose a perfect mix of IO bound and CPU bound processes among the jobs
present in the pool.
• If the job scheduler chooses more IO bound processes then all of the jobs may reside in the
blocked state all the time and the CPU will remain idle most of the time. This will reduce the degree
of Multiprogramming. Therefore, the Job of long term scheduler is very critical and may affect the
system for a very long time.
Short term Schedulers
• Short term scheduler is also known as CPU scheduler. It selects one of the Jobs from the ready
queue and dispatch to the CPU for the execution.
• A scheduling algorithm is used to select which job is going to be dispatched for the execution. The
Job of the short term scheduler can be very critical in the sense that if it selects job whose CPU
burst time is very high then all the jobs after that, will have to wait in the ready queue for a very long
time.
• This problem is called starvation which may arise if the short term scheduler makes some mistakes
while selecting the job.
Medium term Schedulers
• Medium term scheduler takes care of the swapped out processes.If the running state processes
needs some IO time for the completion then there is a need to change its state from running to
waiting.
• Medium term scheduler is used for this purpose. It removes the process from the running state to
make room for the other processes. Such processes are the swapped out processes and this
procedure is called swapping. The medium term scheduler is responsible for suspending and
resuming the processes.
• It reduces the degree of multiprogramming. The swapping is necessary to have a perfect mix of
processes in the ready queue.
Process Schedulers in Operating System
• Process scheduling is the activity of the process manager that handles the removal of the running
process from the CPU and the selection of another process on the basis of a particular strategy.
• Process scheduling is an essential part of a Multiprogramming operating system. Such operating
systems allow more than one process to be loaded into the executable memory at a time and the
loaded process shares the CPU using time multiplexing.
Process Schedulers in Operating System
• Non-preemptive: In this case, a process’s resource cannot be taken before the process has
finished running. When a running process finishes and transitions to a waiting state, resources are
switched.
• Preemptive: In this case, the OS assigns resources to a process for a predetermined period of
time. The process switches from running state to ready state or from waiting for state to ready state
during resource allocation. This switching happens because the CPU may give other processes
priority and substitute the currently active process for the higher priority process.
Scheduling Algorithms in Operating System
• Scheduling algorithms schedule processes on the processor in an efficient and effective manner.
This scheduling is done by a Process Scheduler. It maximizes CPU utilization by increasing
throughput.
1. First-Come, First-Served (FCFS) Scheduling
2. Shortest-Job-Next (SJN) Scheduling
3. Priority Scheduling
4. Shortest Remaining Time
5. Round Robin(RR) Scheduling
6. Multiple-Level Queues Scheduling
7. Multilevel Feedback Queues Scheduling
terminolgoies to be known
Waiting Time = Turn Around Time – Burst Time
•Arrival Time: The time at which the process arrives in the ready queue.
•Completion Time: The time at which the process completes its execution.
•Burst Time: Time required by a process for CPU execution.
•Turn Around Time: Time Difference between completion time and arrival time.
Turn Around Time = Completion Time – Arrival Time
•Waiting Time(W.T): Time Difference between turn around time and burst time.
Waiting Time = Turn Around Time – Burst Time
Scheduling Algorithms in Operating System
First-Come, First-Served (FCFS)
In this scheduling algorithm, jobs are executed on a first come, first serve basis irrespective of burst
time or priority. It is both a preemptive and non-preemptive scheduling algorithm. It is based on the
First In First Out (FIFO) queue.
Scheduling Algorithms in Operating System
• Shortest Job Next (SJN)
• Also known as shortest job first (SJF), this scheduling algorithm is both a non-preemptive and
preemptive scheduling algorithm. Process with the minimum burst time at an instance executes
first. It is very efficient in minimizing the waiting time and is easy to implement in Batch systems. It
cannot be implemented if the required CPU time is not known in advance.
Scheduling Algorithms in Operating System
• Priority Scheduling
•
This scheduling algorithm is commonly used in batch systems and is a non-preemptive scheduling
algorithm. In this each process is assigned a priority and the process with the highest priority
executes first followed by the ones lower in priority. If two processes share the same priority then
execution is done on a first come first served basis. Priority is decided based on memory
requirements, time requirements, or any other resource requirement.
Scheduling Algorithms in Operating System
• Shortest Remaining Time (SRT)
•
This scheduling algorithm is the preemptive version of the SJN algorithm. The OS allocates the
processor to the job that is closest to completion. Though there is a chance of this job being
preempted, if another job is ready with a shorter time to completion. It is used in batch
environments where short jobs are given preference and cannot be implemented in interactive
systems where required CPU time is unknown.
Scheduling Algorithms in Operating System
• Round Robin (RR)
This scheduling algorithm is a preemptive process scheduling algorithm where each process is
provided a fixed time to execute. This fixed time is called a quantum.It uses context switching to
save states of preempted processes. Once a process is done executing for a given time period, it is
preempted and another process executes for a given time period.
Scheduling Algorithms in Operating System
• Multiple-Level Queues
• In this scheduling algorithm multiple algorithms with common characteristics come together to form
a group and then schedule jobs as a whole. Thus, it is not an independent scheduling algorithm.
There are multiple queues for processes with common characteristics and each queue has its own
scheduling algorithms. The OS assigns priorities to each queue.
Unit 2...............................................
Scheduling Algorithms in Operating System
• Multilevel Feedback Queue
• This scheduling algorithm is similar to multilevel queue scheduling except that the processes here
can change their queue too i.e., if a process is in queue1, then after partial execution, it can switch
to queue2.
• There is a list of queues with different priorities and one with a higher priority queue executes first.
During execution of a process with a higher priority queue comes, then the execution of the lower
priority queue stops and the one with higher priority queue replaces it. There is a chance of
starvation if the higher priority queue keeps coming in the ready state and the lower priority queue
keeps waiting for its turn.

More Related Content

PPTX
UNIT I-Processes.pptx
PPTX
UNIT 2 OS.pptx Introduction of Operating System
PDF
Operating System-Concepts of Process
PPTX
Process management system in operating system
PPTX
Process management in operating system, process creation, process sheduling
PPTX
Os unit 3 , process management
PPTX
Operating Systems chap 2_updated2 (1).pptx
PPTX
Operating Systems chap 2_updated2.pptx
UNIT I-Processes.pptx
UNIT 2 OS.pptx Introduction of Operating System
Operating System-Concepts of Process
Process management system in operating system
Process management in operating system, process creation, process sheduling
Os unit 3 , process management
Operating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2.pptx

Similar to Unit 2............................................... (20)

PDF
Process management- This ppt contains all required information regarding oper...
PDF
OS - Process Concepts
PDF
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
PPT
Intro Basic of OS .ppt
PPTX
Chapter -2 operating system presentation
PDF
Lecture 2- Processes.pdf
PPTX
Operating Systems unit 1 & 2 - BBA / MBA
PPTX
Operating Systems - Introduction and unit 1
PDF
process.pdfzljwiyrouyaeutoaetodtusiokklhh
PPTX
Unit 2_OS process management
PPTX
Process Management
PPTX
Processbejdndnnnnnjsnsgsvvdvvvguigv.pptx
PPTX
Processprehsjsjsjskakwkwkejjdbdbdjj.pptx
PPTX
UNIT-2-PROCESS MANAGEMENT in opeartive system.pptx
PPTX
os assignment -individual presenation.pptx
PPTX
PROJECT 3.pptx
PPTX
TOPIC 3.for computer and ict studentspptx
PDF
Unit 2 part 1(Process)
DOC
Operating Systems Unit Two - Fourth Semester - Engineering
PPTX
Process management1
Process management- This ppt contains all required information regarding oper...
OS - Process Concepts
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Intro Basic of OS .ppt
Chapter -2 operating system presentation
Lecture 2- Processes.pdf
Operating Systems unit 1 & 2 - BBA / MBA
Operating Systems - Introduction and unit 1
process.pdfzljwiyrouyaeutoaetodtusiokklhh
Unit 2_OS process management
Process Management
Processbejdndnnnnnjsnsgsvvdvvvguigv.pptx
Processprehsjsjsjskakwkwkejjdbdbdjj.pptx
UNIT-2-PROCESS MANAGEMENT in opeartive system.pptx
os assignment -individual presenation.pptx
PROJECT 3.pptx
TOPIC 3.for computer and ict studentspptx
Unit 2 part 1(Process)
Operating Systems Unit Two - Fourth Semester - Engineering
Process management1
Ad

More from likhithmuthyalu2 (6)

PPTX
Unit 1..............................................................
PPTX
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PPTX
introduction to operating system mmmmmmmmmmmmmmmmmmm
PPTX
Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PPTX
Unit 4-OS.pptx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PPTX
introduction to operating system unit 2
Unit 1..............................................................
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
introduction to operating system mmmmmmmmmmmmmmmmmmm
Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Unit 4-OS.pptx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
introduction to operating system unit 2
Ad

Recently uploaded (20)

PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
Complications of Minimal Access-Surgery.pdf
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
Hazard Identification & Risk Assessment .pdf
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
Uderstanding digital marketing and marketing stratergie for engaging the digi...
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PPTX
20th Century Theater, Methods, History.pptx
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
International_Financial_Reporting_Standa.pdf
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
What if we spent less time fighting change, and more time building what’s rig...
Weekly quiz Compilation Jan -July 25.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
B.Sc. DS Unit 2 Software Engineering.pptx
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Unit 4 Computer Architecture Multicore Processor.pptx
AI-driven educational solutions for real-life interventions in the Philippine...
Complications of Minimal Access-Surgery.pdf
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
Hazard Identification & Risk Assessment .pdf
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Uderstanding digital marketing and marketing stratergie for engaging the digi...
Environmental Education MCQ BD2EE - Share Source.pdf
20th Century Theater, Methods, History.pptx
Share_Module_2_Power_conflict_and_negotiation.pptx
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
International_Financial_Reporting_Standa.pdf
LDMMIA Reiki Yoga Finals Review Spring Summer
What if we spent less time fighting change, and more time building what’s rig...

Unit 2...............................................

  • 2. PROCESS • Process is the execution of a program that performs the actions specified in that program. It can be defined as an execution unit where a program runs. • The OS helps you to create, schedule, and terminates the processes which is used by CPU. A process created by the main process is called a child process. • Process operations can be easily controlled with the help of PCB(Process Control Block). • You can consider it as the brain of the process, which contains all the crucial information related to processing like process id, priority, state, CPU registers, etc.
  • 3. What is Process Management? • Process management involves various tasks like creation, scheduling, termination of processes, and a dead lock. • Process is a program that is under execution, which is an important part of modern-day operating systems. • The OS must allocate resources that enable processes to share and exchange information. It also protects the resources of each process from other methods and allows synchronization among processes. • It is the job of OS to manage all the running processes of the system. It handles operations by performing tasks like process scheduling and such as resource allocation.
  • 4. •Stack: The Stack stores temporary data like function parameters, returns addresses, and local variables. •Heap Allocates memory, which may be processed during its run time. •Data: It contains the variable. •Text: Text Section includes the current activity, which is represented by the value of the Program Counter. How does the process look like in memeory
  • 5. Attributes or Characteristics of a Process A process has the following attributes. 1.Process Id: A unique identifier assigned by the operating system 2.Process State: Can be ready, running, etc. 3.CPU registers: Like the Program Counter (CPU registers must be saved and restored when a process is swapped in and out of the CPU) 4.Accounts information: Amount of CPU used for process execution, time limits, execution ID, etc 5.I/O status information: For example, devices allocated to the process, open files, etc 6.CPU scheduling information: For example, Priority (Different processes may have different priorities, for example, a shorter process assigned high priority in the shortest job first scheduling) .
  • 6. States of Process 1. New: Newly Created Process (or) being-created process. 2. Ready: After the creation process moves to the Ready state, i.e. the process is ready for execution. 3. Run: Currently running process in CPU (only one process at a time can be under execution in a single processor) 4. Wait (or Block): When a process requests I/O access. 5. Complete (or Terminated): The process completed its execution. 6. Suspended Ready: When the ready queue becomes full, some processes are moved to a suspended ready state 7. Suspended Block: When the waiting queue becomes full.
  • 7. Process Control Block • With the creation of a process, a PCB is created which controls how that process is being carried out. • The PCB is created with the aim of helping the OS to manage the enormous amounts of tasks that are being carried out in the system. • PCB is helpful in doing that as it helps the OS to actively monitor the process and redirect system resources to each process accordingly. • The OS creates a PCB for every process which is created, and it contains all the important information about the process. All this information is afterward used by the OS to manage processes and run them efficiently.
  • 9. Process Control Block • Process State: The state of the process is stored in the PCB which helps to manage the processes and schedule them. There are different states for a process which are “running,” “waiting,” “ready,” or “terminated.” • Process ID: The OS assigns a unique identifier to every process as soon as it is created which is known as Process ID, this helps to distinguish between processes. • Program Counter: While running processes when the context switch occurs the last instruction to be executed is stored in the program counter which helps in resuming the execution of the process from where it left off. • CPU Registers: The CPU registers of the process helps to restore the state of the process so the PCB stores a copy of them. • Memory Information: The information like the base address or total memory allocated to a process is stored in PCB which helps in efficient memory allocation to the processes. • Process Scheduling Information: The priority of the processes or the algorithm of scheduling is stored in the PCB to help in making scheduling decisions of the OS. • Accounting Information: The information such as CPU time, memory usage, etc helps the OS to monitor the performance of the process.
  • 10. Operations that are Carried out with the help of PCB • Process Scheduling: The different information like Process priority, process state, and resources used can be used by the OS to schedule the process on the execution stack. The scheduler checks the priority and other information to set when the process will be executed. • Multitasking: Resource allocation, process scheduling, and process synchronization altogether helps the OS to multitask and run different processes simultaneously. • Context Switching: When context switching happens in the OS the process state is saved in the CPU register and a copy of it is stored in the PCB. When the CPU switches to another process and then switches back to that process the CPU fetches that value from the PCB and restores the previous state of the process. • Resources Sharing: The PCB stores information like the resources that a process is using, such as files open and memory allocated. This information helps the OS to let a new process use the resources which are being used by any other process to execute sharing of the resources.
  • 11. Independent and Cooperating Processes • Independent Process: Independent Processes are those processes whose task is not dependent on any other processes. • Cooperating Process: Cooperating Processes are those processes that depend on other processes or processes. They work together to achieve a common task in an operating system. These processes interact with each other by sharing the resources such as CPU, memory, and I/O devices to complete the task.
  • 12. Inter Process Communication (IPC) • Inter process communication (IPC) is used for exchanging data between multiple threads in one or more processes or programs. The Processes may be running on single or multiple computers connected by a network. The full form of IPC is Inter-process communication. • It is a set of programming interface which allow a programmer to coordinate activities among various program processes which can run concurrently in an operating system. This allows a specific program to handle many user requests at the same time. • Since every single user request may result in multiple processes running in the operating system, the process may require to communicate with each other. Each IPC protocol approach has its own advantage and limitation, so it is not unusual for a single program to use all of the IPC methods.
  • 13. Role of Synchronization in Inter Process Communication • Inter process communication (IPC) is used for exchanging data between multiple threads in one or more processes or programs. The Processes may be running on single or multiple computers connected by a network. The full form of IPC is Inter-process communication. • It is a set of programming interface which allow a programmer to coordinate activities among various program processes which can run concurrently in an operating system. This allows a specific program to handle many user requests at the same time. • Since every single user request may result in multiple processes running in the operating system, the process may require to communicate with each other. Each IPC protocol approach has its own advantage and limitation, so it is not unusual for a single program to use all of the IPC methods.
  • 14. Role of Synchronization in Inter Process Communication • It is one of the essential parts of inter process communication. Typically, this is provided by interprocess communication control mechanisms, but sometimes it can also be controlled by communication processes. • These are the following methods that used to provide the synchronization: 1. Mutual Exclusion 2. Semaphore 3. Barrier 4. Spinlock
  • 15. Role of Synchronization in Inter Process Communication Mutual Exclusion:- •It is generally required that only one process thread can enter the critical section at a time. This also helps in synchronization and creates a stable state to avoid the race condition. Semaphore:- •Semaphore is a type of variable that usually controls the access to the shared resources by several processes. Semaphore is further divided into two types which are as follows: 1.Binary Semaphore 2.Counting Semaphore
  • 16. Role of Synchronization in Inter Process Communication Barrier:- •A barrier typically not allows an individual process to proceed unless all the processes does not reach it. It is used by many parallel languages, and collective routines impose barriers. •Spinlock:- •Spinlock is a type of lock as its name implies. The processes are trying to acquire the spinlock waits or stays in a loop while checking that the lock is available or not. It is known as busy waiting because even though the process active, the process does not perform any functional operation (or task).
  • 17. Approaches to Interprocess Communication Barrier:- •A barrier typically not allows an individual process to proceed unless all the processes does not reach it. It is used by many parallel languages, and collective routines impose barriers. •Spinlock:- •Spinlock is a type of lock as its name implies. The processes are trying to acquire the spinlock waits or stays in a loop while checking that the lock is available or not. It is known as busy waiting because even though the process active, the process does not perform any functional operation (or task).
  • 18. Approaches to Interprocess Communication
  • 19. Process Scheduling • The process scheduling is the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process on the basis of a particular strategy. • Process scheduling is an essential part of a Multiprogramming operating systems. Such operating systems allow more than one process to be loaded into the executable memory at a time and the loaded process shares the CPU using time multiplexing. • Process scheduling is the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process on the basis of a particular strategy. • Process scheduling is an essential part of a Multiprogramming operating system. Such operating systems allow more than one process to be loaded into the executable memory at a time and the loaded process shares the CPU using time multiplexing.
  • 20. Process Scheduling Queues • The OS maintains all Process Control Blocks (PCBs) in Process Scheduling Queues. The OS maintains a separate queue for each of the process states and PCBs of all processes in the same execution state are placed in the same queue. When the state of a process is changed, its PCB is unlinked from its current queue and moved to its new state queue. • The Operating System maintains the following important process scheduling queues − • Job queue − This queue keeps all the processes in the system. • Ready queue − This queue keeps a set of all processes residing in main memory, ready and waiting to execute. A new process is always put in this queue. • Device queues − The processes which are blocked due to unavailability of an I/O device constitute this queue.
  • 21. Types Of Schedulers • Long term Schedulers • Short term Schedulers • Medium term Schedulers
  • 22. Long term Schedulers • Long term scheduler is also known as job scheduler. It chooses the processes from the pool (secondary memory) and keeps them in the ready queue maintained in the primary memory. • Long Term scheduler mainly controls the degree of Multiprogramming. The purpose of long term scheduler is to choose a perfect mix of IO bound and CPU bound processes among the jobs present in the pool. • If the job scheduler chooses more IO bound processes then all of the jobs may reside in the blocked state all the time and the CPU will remain idle most of the time. This will reduce the degree of Multiprogramming. Therefore, the Job of long term scheduler is very critical and may affect the system for a very long time.
  • 23. Short term Schedulers • Short term scheduler is also known as CPU scheduler. It selects one of the Jobs from the ready queue and dispatch to the CPU for the execution. • A scheduling algorithm is used to select which job is going to be dispatched for the execution. The Job of the short term scheduler can be very critical in the sense that if it selects job whose CPU burst time is very high then all the jobs after that, will have to wait in the ready queue for a very long time. • This problem is called starvation which may arise if the short term scheduler makes some mistakes while selecting the job.
  • 24. Medium term Schedulers • Medium term scheduler takes care of the swapped out processes.If the running state processes needs some IO time for the completion then there is a need to change its state from running to waiting. • Medium term scheduler is used for this purpose. It removes the process from the running state to make room for the other processes. Such processes are the swapped out processes and this procedure is called swapping. The medium term scheduler is responsible for suspending and resuming the processes. • It reduces the degree of multiprogramming. The swapping is necessary to have a perfect mix of processes in the ready queue.
  • 25. Process Schedulers in Operating System • Process scheduling is the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process on the basis of a particular strategy. • Process scheduling is an essential part of a Multiprogramming operating system. Such operating systems allow more than one process to be loaded into the executable memory at a time and the loaded process shares the CPU using time multiplexing.
  • 26. Process Schedulers in Operating System • Non-preemptive: In this case, a process’s resource cannot be taken before the process has finished running. When a running process finishes and transitions to a waiting state, resources are switched. • Preemptive: In this case, the OS assigns resources to a process for a predetermined period of time. The process switches from running state to ready state or from waiting for state to ready state during resource allocation. This switching happens because the CPU may give other processes priority and substitute the currently active process for the higher priority process.
  • 27. Scheduling Algorithms in Operating System • Scheduling algorithms schedule processes on the processor in an efficient and effective manner. This scheduling is done by a Process Scheduler. It maximizes CPU utilization by increasing throughput. 1. First-Come, First-Served (FCFS) Scheduling 2. Shortest-Job-Next (SJN) Scheduling 3. Priority Scheduling 4. Shortest Remaining Time 5. Round Robin(RR) Scheduling 6. Multiple-Level Queues Scheduling 7. Multilevel Feedback Queues Scheduling
  • 28. terminolgoies to be known Waiting Time = Turn Around Time – Burst Time •Arrival Time: The time at which the process arrives in the ready queue. •Completion Time: The time at which the process completes its execution. •Burst Time: Time required by a process for CPU execution. •Turn Around Time: Time Difference between completion time and arrival time. Turn Around Time = Completion Time – Arrival Time •Waiting Time(W.T): Time Difference between turn around time and burst time. Waiting Time = Turn Around Time – Burst Time
  • 29. Scheduling Algorithms in Operating System First-Come, First-Served (FCFS) In this scheduling algorithm, jobs are executed on a first come, first serve basis irrespective of burst time or priority. It is both a preemptive and non-preemptive scheduling algorithm. It is based on the First In First Out (FIFO) queue.
  • 30. Scheduling Algorithms in Operating System • Shortest Job Next (SJN) • Also known as shortest job first (SJF), this scheduling algorithm is both a non-preemptive and preemptive scheduling algorithm. Process with the minimum burst time at an instance executes first. It is very efficient in minimizing the waiting time and is easy to implement in Batch systems. It cannot be implemented if the required CPU time is not known in advance.
  • 31. Scheduling Algorithms in Operating System • Priority Scheduling • This scheduling algorithm is commonly used in batch systems and is a non-preemptive scheduling algorithm. In this each process is assigned a priority and the process with the highest priority executes first followed by the ones lower in priority. If two processes share the same priority then execution is done on a first come first served basis. Priority is decided based on memory requirements, time requirements, or any other resource requirement.
  • 32. Scheduling Algorithms in Operating System • Shortest Remaining Time (SRT) • This scheduling algorithm is the preemptive version of the SJN algorithm. The OS allocates the processor to the job that is closest to completion. Though there is a chance of this job being preempted, if another job is ready with a shorter time to completion. It is used in batch environments where short jobs are given preference and cannot be implemented in interactive systems where required CPU time is unknown.
  • 33. Scheduling Algorithms in Operating System • Round Robin (RR) This scheduling algorithm is a preemptive process scheduling algorithm where each process is provided a fixed time to execute. This fixed time is called a quantum.It uses context switching to save states of preempted processes. Once a process is done executing for a given time period, it is preempted and another process executes for a given time period.
  • 34. Scheduling Algorithms in Operating System • Multiple-Level Queues • In this scheduling algorithm multiple algorithms with common characteristics come together to form a group and then schedule jobs as a whole. Thus, it is not an independent scheduling algorithm. There are multiple queues for processes with common characteristics and each queue has its own scheduling algorithms. The OS assigns priorities to each queue.
  • 36. Scheduling Algorithms in Operating System • Multilevel Feedback Queue • This scheduling algorithm is similar to multilevel queue scheduling except that the processes here can change their queue too i.e., if a process is in queue1, then after partial execution, it can switch to queue2. • There is a list of queues with different priorities and one with a higher priority queue executes first. During execution of a process with a higher priority queue comes, then the execution of the lower priority queue stops and the one with higher priority queue replaces it. There is a chance of starvation if the higher priority queue keeps coming in the ready state and the lower priority queue keeps waiting for its turn.