Operating
System
Chapter: 2
Process and Scheduling
Process Concepts and Scheduling
What is a Process in OS?
●A process is an instance of a computer program that is being executed. It's
●Processes have their own memory space, CPU state, and resources,
allowing multiple tasks to be executed concurrently.
●Processes in operating systems are fundamental entities that enable
multitasking and concurrent execution. Each process is essentially an
independent unit of execution, encapsulating its code, data, and
execution context.
the basic unit of work in a system.
Process States
●Running:
●
t h e C P U t o b e a l l o c a t e d .
●
such as user input or I/O operation completion.
The process is currently being executed by the CPU.
Ready:
●Terminated:
Blocked (or Waiting):
The process has finished execution.
Theprocessisready to be executed but is waiting for
Theprocessiswaitingfor some event,
Process States
●Processes transition between these states is based on
variousevents,suchasI/Ocompletion,timerinterrupts,
or resource availability.
●Efficiently managing these state transitions is essential
for optimizing system performance and resource
utilization.
Process Scheduling
•Process scheduling is a critical aspect of operating system
design, aiming to allocateCPU resourcesefficientlywhile
meeting various performance metrics.
•It involves selecting an available process and allocating the CPU
toit, basedon a specific strategy.
•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.
Goals of Process Scheduling
Maximizing CPU Utilization:Ensuring that the CPU is utilized to
user requests.
its fullest extent.
Fairness:Providing equal opportunities for all processes to
execute.
Optimizing Turnaround Time: Minimizing the time taken from the
submission of a process to its completion.
BalancingResponse Time:Ensuring prompt responsiveness to
Scheduling Algorithms
-First-Come,First-Served (FCFS):
time next.
Processes are executed in the order
they arrive.
-Round Robin:Each process is executed for a fixed time quantum, then
moved to the end of the queue.
-Priority Scheduling:Processes are assigned priorities, with higher-priority
processes executed first.
-Multilevel Queue: Divides processes into different queues based on
characteristics like priority or process type.
Executes the process with the smallest execution
-ShortestJob Next (SJN):
Scheduling Algorithms
Process Synchronization
●Process synchronization in an operating system is all about
coordinatingmultiple processes(or tasks) so theycanwork
together smoothly without causing conflicts or inconsistencies.
●It involves methods and techniques to ensure that processes
share resources, communicate effectively, and avoid problems
like race conditions or deadlock. Basically, it's like making sure
everyone takes turns and plays nicely in the computer system.
Process Synchronization
Concurrency Issues
●Race Conditions:
●Deadlocks:
Multiple processes or threads accessing shared
●Starvation:A process is perpetually denied access to a resource it needs
due to higher-priority processes continuously acquiring it.
Situations where two or more processes are indefinitely blocked
waiting for each other to release resources.
resources concurrently, leading to unpredictable outcomes.
Inter-Process Communication (IPC)
●
●
●
Inter-Process Communication (IPC) mechanisms enable
processes to communicate and synchronize with each other,
facilitating collaboration and coordination in advanced
operating systems.
Processes often need to share data, coordinate actions, or
share access to resources, necessitating efficient IPC
mechanisms. Since processes run in isolated memory spaces,
they can’t
directly access each other’s data. IPC provides ways for them
to exchange data, signals, and synchronization
information safely and efficiently.
Need for Inter-Process Communication
•Data Sharing:Processes may need to exchange data or
information.
•Coordination:Processes may need to synchronize their actions
or cooperate in completing a task.
•Resource Sharing:Processes may need to share access to
resources such as files, devices, or memory.
●To allow modular and distributed application designs.
●To avoid conflicts when accessing shared resources.
Types of Inter-Process Communication Methods
IPC Method
Pipes
Message Queues
Shared Memory
Semaphores
Sockets
Signals
Description
Unidirectional or bidirectional communication channel between
related processes.
Messages are sent to and received from a queue. Asynchronous
communication.
Multiple processes can access the same memory region. Fast, but
needs synchronization (like semaphores).
Used for signaling and synchronizing access to resources.
Used for communication between processes over a network or on
the same machine.
Lightweight way to notify a process that an event has occurred.
IPC Mechanisms
•Shared Memory:Processes share a region of memory for
communication. It allows processes to exchange data by sharing
a common region of memory, providing high-speed
communication but requiring careful synchronization to prevent
data corruption.
•Message Passing: Processes exchange messages through the
operating system kernel, providing a more structured approach to
communication.
IPC Mechanisms
●Pipes and FIFOs:
●Pipes and FIFOs (First-In, First-Out) provide
unidirectional communication channels between
processes,typicallyusedforsequentialdata flow.
●Sockets:
●
networked processes, enabling communication over local
or networked environments with protocols like TCP/IP.
Socketsserveascommunicationendpoints for
process types of process schduling algorithms

process types of process schduling algorithms

  • 1.
  • 2.
    Process Concepts andScheduling What is a Process in OS? ●A process is an instance of a computer program that is being executed. It's ●Processes have their own memory space, CPU state, and resources, allowing multiple tasks to be executed concurrently. ●Processes in operating systems are fundamental entities that enable multitasking and concurrent execution. Each process is essentially an independent unit of execution, encapsulating its code, data, and execution context. the basic unit of work in a system.
  • 3.
    Process States ●Running: ● t he C P U t o b e a l l o c a t e d . ● such as user input or I/O operation completion. The process is currently being executed by the CPU. Ready: ●Terminated: Blocked (or Waiting): The process has finished execution. Theprocessisready to be executed but is waiting for Theprocessiswaitingfor some event,
  • 4.
    Process States ●Processes transitionbetween these states is based on variousevents,suchasI/Ocompletion,timerinterrupts, or resource availability. ●Efficiently managing these state transitions is essential for optimizing system performance and resource utilization.
  • 6.
    Process Scheduling •Process schedulingis a critical aspect of operating system design, aiming to allocateCPU resourcesefficientlywhile meeting various performance metrics. •It involves selecting an available process and allocating the CPU toit, basedon a specific strategy. •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.
  • 7.
    Goals of ProcessScheduling Maximizing CPU Utilization:Ensuring that the CPU is utilized to user requests. its fullest extent. Fairness:Providing equal opportunities for all processes to execute. Optimizing Turnaround Time: Minimizing the time taken from the submission of a process to its completion. BalancingResponse Time:Ensuring prompt responsiveness to
  • 8.
    Scheduling Algorithms -First-Come,First-Served (FCFS): timenext. Processes are executed in the order they arrive. -Round Robin:Each process is executed for a fixed time quantum, then moved to the end of the queue. -Priority Scheduling:Processes are assigned priorities, with higher-priority processes executed first. -Multilevel Queue: Divides processes into different queues based on characteristics like priority or process type. Executes the process with the smallest execution -ShortestJob Next (SJN):
  • 9.
  • 10.
    Process Synchronization ●Process synchronizationin an operating system is all about coordinatingmultiple processes(or tasks) so theycanwork together smoothly without causing conflicts or inconsistencies. ●It involves methods and techniques to ensure that processes share resources, communicate effectively, and avoid problems like race conditions or deadlock. Basically, it's like making sure everyone takes turns and plays nicely in the computer system.
  • 11.
    Process Synchronization Concurrency Issues ●RaceConditions: ●Deadlocks: Multiple processes or threads accessing shared ●Starvation:A process is perpetually denied access to a resource it needs due to higher-priority processes continuously acquiring it. Situations where two or more processes are indefinitely blocked waiting for each other to release resources. resources concurrently, leading to unpredictable outcomes.
  • 12.
    Inter-Process Communication (IPC) ● ● ● Inter-ProcessCommunication (IPC) mechanisms enable processes to communicate and synchronize with each other, facilitating collaboration and coordination in advanced operating systems. Processes often need to share data, coordinate actions, or share access to resources, necessitating efficient IPC mechanisms. Since processes run in isolated memory spaces, they can’t directly access each other’s data. IPC provides ways for them to exchange data, signals, and synchronization information safely and efficiently.
  • 13.
    Need for Inter-ProcessCommunication •Data Sharing:Processes may need to exchange data or information. •Coordination:Processes may need to synchronize their actions or cooperate in completing a task. •Resource Sharing:Processes may need to share access to resources such as files, devices, or memory. ●To allow modular and distributed application designs. ●To avoid conflicts when accessing shared resources.
  • 14.
    Types of Inter-ProcessCommunication Methods IPC Method Pipes Message Queues Shared Memory Semaphores Sockets Signals Description Unidirectional or bidirectional communication channel between related processes. Messages are sent to and received from a queue. Asynchronous communication. Multiple processes can access the same memory region. Fast, but needs synchronization (like semaphores). Used for signaling and synchronizing access to resources. Used for communication between processes over a network or on the same machine. Lightweight way to notify a process that an event has occurred.
  • 15.
    IPC Mechanisms •Shared Memory:Processesshare a region of memory for communication. It allows processes to exchange data by sharing a common region of memory, providing high-speed communication but requiring careful synchronization to prevent data corruption. •Message Passing: Processes exchange messages through the operating system kernel, providing a more structured approach to communication.
  • 16.
    IPC Mechanisms ●Pipes andFIFOs: ●Pipes and FIFOs (First-In, First-Out) provide unidirectional communication channels between processes,typicallyusedforsequentialdata flow. ●Sockets: ● networked processes, enabling communication over local or networked environments with protocols like TCP/IP. Socketsserveascommunicationendpoints for