0% found this document useful (0 votes)
78 views26 pages

Process Management in Operating Systems

The document discusses process management in an operating system. It defines a process as a program in execution that progresses sequentially. A process includes code, data, heap, stack, and program counter sections. It then compares the differences between a program and a process. The rest of the document discusses process states, process control blocks, process scheduling including scheduling queues, context switching, and different types of schedulers. It also covers inter-process communication.

Uploaded by

Nisarg Gugale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views26 pages

Process Management in Operating Systems

The document discusses process management in an operating system. It defines a process as a program in execution that progresses sequentially. A process includes code, data, heap, stack, and program counter sections. It then compares the differences between a program and a process. The rest of the document discusses process states, process control blocks, process scheduling including scheduling queues, context switching, and different types of schedulers. It also covers inter-process communication.

Uploaded by

Nisarg Gugale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SUBJECT : OPERATING SYSTEM (22516)

UNIT -3

PROCESS MANAGEMENT

Marks-14

By - [Link]
Process Management

• Introduction-
• Process- A program in execution.
• Process execution must progress in sequential fashion.
• A Process includes following sections-
1. Text – Program Code
2. Data – Global & Static Variables
3. Heap – Dynamic Memory Allocation
4. Stack – Local Variables, Temporary data
5. Program Counter – Contents of Processor’s Registers
Process Management
Sr. No. Program Process
Program contains a set of instructions designed to complete a
1. Process is an instance of an executing program.
specific task.

Process is a active entity as it is created during execution and


2. Program is a passive entity as it resides in the secondary memory.
loaded into the main memory.

Program exists at a single place and continues to exist until it is Process exists for a limited span of time as it gets terminated after
3.
deleted. the completion of task.

4. Program is a static entity. Process is a dynamic entity.

Program does not have any resource requirement, it only Process has a high resource requirement, it needs resources like
5.
requires memory space for storing the instructions. CPU, memory address, I/O during its lifetime.

6. Program does not have any control block. Process has its own control block called Process Control Block.

In addition to program data, a process also requires additional


7. Program has two logical components: code and data.
information required for the management and execution.

Many processes may execute a single program. There program


8. Program does not change itself. code may be the same but program data may be different. these
are never same.
Process Management

Process Model:
• OS is organized into a number of sequential processes.
• Conceptually each process has its own virtual CPU.

Program Counter
Four Program Counter D
A
C
B
A B C D
B
C
A
D
Fig.b
Time
Fig.a
Process
Process Management

Process States
• As Process run it change its state.
Process States means various
stages of process.
1. New
2. Ready
3. Running
4. Waiting
5. Terminated

Process Cycle/ Process State Cycle


Process Management

• Process Control Block (PCB)-


• Information associated with each process
a) Process state
b) Process number
c) Program counter
d) Register
e) Memory Management
f) Accounting Information
g) I/O status Information
Process Management

• Process Scheduling-
• Main objectives of Operating system is multiprogramming .
• It means to run multiple program at a time. So it can use more CPU and I/O
devices.
• Process are arranged in a queue and each process is associated with its PCB.
• Types of Process Scheduling-
1. Scheduling Queues-
2. Context Switching-
3. Schedulers-
Process Management
1. Scheduling Queues-
• There are various types of process scheduling queues.
• Job queue – set of all processes in the system.
• Ready queue – set of all processes residing in main memory, ready and waiting to execute.
• Device queue – set of processes waiting for an I/O device.
• Representation of Process Scheduling-
Process Management
2. Context Switching-
Process Management

2. Context Switching-
• A context switch is a procedure that a computer's CPU (central processing
unit) follows to change from one task (or process) to another while ensuring
that the tasks do not conflict. Effective context switching is critical if a
computer is to provide user-friendly multitasking.
• Diagram Shows two Processes Process P0 and Process P1.
• Situation could describe when P0 run at same time P1 wait (idle) and when P1
run P0 is idle.
• In that role of operating system is to invoke the system call in between switch
and save the current state of those process in respective process control block.
Process Management

3. Schedulers-
• Schedulers are special system software which handle process scheduling in
various ways.
• Their main task is to select the jobs to be submitted into the system and to
decide which process to run.
• Schedulers are of three types −
1. Long term Schedulers
2. Short term Schedulers
3. Medium term Schedulers
Process Management
1. Long term Schedulers-
• It is also called a job scheduler.
• A long-term scheduler determines which programs are admitted to the
system for processing.
• It selects processes from the queue and loads them into memory for
execution. Process loads into the memory for CPU scheduling.
• The primary objective of the job scheduler is to provide a balanced mix of
jobs, such as I/O bound and processor bound.
• On some systems, the long-term scheduler may not be available or minimal.
• Time-sharing operating systems have no long term scheduler.
• When a process changes the state from new to ready, then there is use of
long-term scheduler.
Process Management
2. Short term Schedulers-
• It is also called as CPU scheduler.
• Its main objective is to increase system performance in accordance with the
chosen set of criteria.
• It is the change of ready state to running state of the process.
• CPU scheduler selects a process among the processes that are ready to
execute and allocates CPU to one of them.
• Short-term schedulers, also known as dispatchers, make the decision of
which process to execute next.
• Short-term schedulers are faster than long-term schedulers.
Process Management
3. Medium Term Scheduler
• Medium-term scheduling is a part of swapping.
• It removes the processes from the memory.
• It reduces the degree of multiprogramming. The medium-term scheduler is
in-charge of handling the swapped out-processes.
• A running process may become suspended if it makes an I/O request.
• A suspended processes cannot make any progress towards completion. In
this condition, to remove the process from memory and make space for other
processes, the suspended process is moved to the secondary storage.
• This process is called swapping, and the process is said to be swapped out or
rolled out. Swapping may be necessary to improve the process mix.
Process Management
Comparison-
S.N. Long-Term Scheduler Short-Term Scheduler Medium-Term Scheduler

1 It is a job scheduler It is a CPU scheduler It is a process swapping


scheduler.
2 Speed is lesser than short term Speed is fastest among other two Speed is in between both short
scheduler and long term scheduler.

3 It controls the degree of It provides lesser control over It reduces the degree of
multiprogramming degree of multiprogramming multiprogramming.

4 It is almost absent or minimal in It is also minimal in time sharing It is a part of Time sharing
time sharing system system systems.
5 It selects processes from pool and It selects those processes which It can re-introduce the process
loads them into memory for are ready to execute into memory and execution can
execution be continued.
Process Management
Inter-process communication (IPC)-
• Inter-process communication is the mechanism provided by the operating
system that allows processes to communicate with each other.

• This communication could involve a process letting another process know


that some event has occurred or transferring of data from one process to
another.
Process Management
Inter-process communication(IPC)-
• There are certain reasons due to which Co-operating environment is
needed.
1. Information Sharing-
2. Computational Speed up-
3. Modularity-
4. Convenience-
• There are two fundamental Models of IPC-
1. Shared memory model-
2. Message passing model-
Process Management
Inter-process communication(IPC)-
• There are two fundamental Models of IPC-
1. Message passing model-
2. Shared memory model-
Process Management
Inter-process communication(IPC)-
• There are two fundamental Models of IPC-
1. Message passing model-
• Multiple processes can read and write data to the message queue without being
connected to each other.
• Messages are stored on the queue until their recipient retrieves them. Message queues
are quite useful for inter-process communication and are used by most operating
systems.
• Advantage -
• The message passing model is much easier to implement than the shared memory
model.
• Disadvantage -
• The message passing model has slower communication than the shared memory model
because the connection setup takes time.
Process Management
Inter-process communication(IPC)-
• Shared memory model-
• Shared memory is the memory that can be simultaneously accessed by multiple
processes. This is done so that the processes can communicate with each other.
Windows operating systems use shared memory.
• Advantage -
Memory communication is faster on the shared memory model as compared to
the message passing model on the same machine.
• Disadvantages -
1. All the processes that use the shared memory model need to make sure that
they are not writing to the same memory location.
2. Shared memory model may create problems such as synchronization and
memory protection that need to be addressed.
Process Management
Thread-
• A fundamental unit of CPU utilization. Thread is associated with thread ID,
Program counter ,a register set and stack.
• To examine issues related to multithreaded programming.
• Single and Multithreaded Processes-
Process Management
• Benefits of Multi threaded Programming-
1. Responsiveness-
2. Resource Sharing –
3. Economy-
4. Utilization of multi processor Architecture-
• User Thread And Kernel Thread-
a) Support for creating thread is done on two level i.e User level and Kernel level.
b) User level Thread is called as User Thread.
c) Kernel Level Thread is called as Kernel Thread.
d) User Thread s are supported above the kernel and manage Without kernel support.
e) On the other hand Operating system support and manages kernel thread.
Process Management
• Multi threading model-
• There are three models-
1. Many to One Model-
2. One to One Model-
3. Many to Many Model-
Process Management
• Multi threading model-
1. Many to One Model-
Process Management
• Multi threading model-
2. One to One Model-
Process Management
• Multi threading model-
[Link] to Many Model-

Common questions

Powered by AI

The Many-to-One model is suitable for environments with limited threaded execution requirements but can suffer from bottlenecks. The One-to-One model offers better concurrency and is apt for applications requiring high responsiveness. The Many-to-Many model provides optimal flexibility and scalability for systems that execute numerous threads, balancing workload efficiently across processors .

The process cycle includes states like New, Ready, Running, Waiting, and Terminated. Transitions between these states are crucial for resource management and efficiency. For example, a process moves from New to Ready when admitted by the long-term scheduler, from Ready to Running when chosen by the short-term scheduler, and to Waiting if requiring I/O. Understanding these transitions helps optimize scheduling and resource allocation .

Medium-term schedulers manage memory usage by swapping processes in and out of memory, thus controlling the degree of multiprogramming. By suspending less critical processes, they free up memory for active processes, improving the process mix and overall efficiency, though it can induce latency due to swapping overhead .

Context switching enables multitasking by allowing the CPU to switch between different processes, saving the current state of one process and restoring the state of another. This facilitates user-friendly multitasking by preventing workflow conflicts but can introduce overhead due to the time required to save and load process states .

Scheduling queues categorize tasks into groups like Job Queue, Ready Queue, and Device Queue, allowing for organized process management. This categorization helps efficiently allocate CPU time and manage waiting processes, optimizing system throughput by prioritizing tasks based on their current state and requirements .

The shared memory model poses synchronization challenges as processes must avoid writing to the same memory location simultaneously, which can lead to inconsistencies. Additionally, ensuring memory protection to prevent unauthorized access and ensure data integrity is complex, requiring careful implementation of locks or semaphores .

Message passing is easier to implement than shared memory and supports communication through messages queued until retrieval, but this setup leads to slower communication. Shared memory, by allowing multiple access to the same memory space, facilitates faster communication but requires careful synchronization to avoid conflicts and to ensure memory protection, which can be challenging .

Schedulers manage process execution by selecting jobs for processing and deciding which process runs on the CPU. Long-term schedulers determine which programs enter the system, short-term schedulers select from ready processes to execute next, and medium-term schedulers handle process swapping to manage the degree of multiprogramming. Their functions collectively aim to balance resource utilization and improve system performance .

Multithreaded programming enhances system responsiveness as threads can handle separate tasks concurrently, improving interaction with users. It also facilitates resource sharing, as threads of the same process use common data segments and resources efficiently, reducing the need for additional memory allocations and overhead .

A process is an instance of an executing program that is active and requires resources like CPU, memory addresses, and I/O during its lifetime, while a program is a passive set of instructions stored in secondary memory requiring only memory space. A process is dynamic and exists temporarily, whereas a program is static and exists until deletion .

You might also like