OperatingSystemConcepts 4 Processes
OperatingSystemConcepts 4 Processes
• Process Concept
• Process Scheduling
• Operations on Processes
• Cooperating Processes
• Inter-process Communication
2
• Program counter
• Next instruction
3
• Stack
• Local variables
• Return addresses
• Method parameters
4
• Data section
• Global variables
© Copyright Information Technology Institute - 2018 6
Process State
new btb2a ready lma yt7gzlha el resources bt3tha
scheduler dispatch : choose from the processes in ready state to make them run ( choosing depends on its algorithm)
Process number
Program counter
CPU registers
Accounting Information
• Multi-Programming systems
• Some processes executing at all times
• Maximize CPU utilization
• Time-Sharing systems
• Switch the CPU among processes frequently
• Users can interact with a program while it’s
executing
• Virtually run processes at the same time
© Copyright Information Technology Institute - 2018 13
Process Scheduling Queues
• Job queue
• set of all processes in the system.
• Ready queue
• set of all processes residing in main memory which is
ready and waiting to execute.
• Device queues
• set of processes waiting for an I/O device.
time slice
expired
wait for an
interrupt occurs
interrupt
© Copyright Information Technology Institute - 2018 16
Schedulers
• Executes infrequently
• May be absent in some O/S
• Short-term scheduler (or CPU scheduler)
• Selects which process should be executed next
and allocates CPU. choose from ready state
• Executes frequently
© Copyright Information Technology Institute - 2018 17
Addition of Medium Term
Scheduling
from running to ready again , most probably m=by5rgo mn el main memory to virtual memory l7d my7tago tani
Medium-term scheduling is responsible for managing processes that are in a "Blocked" or "Waiting" state. This type of scheduling is
not as well-known or as frequently discussed as short-term (CPU scheduling) or long-term (job scheduling) scheduling. However, it
plays an important role in some operating systems, particularly those that use a multi-level queue-based scheduling approach.
1. **Blocked Process Management:** When a process cannot continue its execution because it's waiting for some event or resource
(e.g., reading data from disk, receiving input from a user, waiting for a network packet), it is moved from the "Ready" state to the " 18
© Copyright
Blocked" or "Waiting" state. Medium-term scheduling is responsible for managing Information
these Technology Institute - 2018
blocked processes.
Schedulers Cont’d
• Processes can be described as either:
• I/O-bound process
• spends more time doing I/O than computations, many short CPU bursts.
• CPU-bound process
• spends more time doing computations; few very long CPU bursts.
• Process Creation
• Process Termination
* Process resources
• CPU time
• Memory
• Files
• I/O devices
© Copyright Information Technology Institute - 2018 22
Process Creation
Process n
Process n
Process n+1
Process n+1 Process n+2
Process n+2
Process n+3
Process n+3
Process n+4
Process n+4
Process n+5 Process n+6
Process n+5
© Copyright Information Technology Institute - 2018 23
Process Creation Cont’d
• Execution
• Parent and children execute concurrently.m3 b3d
• Parent waits until children terminate.
© Copyright Information Technology Institute - 2018 24
Process Creation Cont’d
• Address space
• Child duplicate of parent.
• Child has a program loaded into it.
• UNIX examples
• fork system call creates new process
• exec system call used after a fork to replace the
process’ memory space with a new program.
• Message Passing
• Shared Memory
* Synchronization
• Messages
• Fixed size
• Variable size
• Communication
• Direct:
• send(P2, message), receive(P1, message)
• Indirect:
• send(ID, message), receive(ID, messages)
© Copyright Information Technology Institute - 2018 30
Synchronization