OperatingSystemConcepts 4 Processes
OperatingSystemConcepts 4 Processes
• Process Concept
• Process Scheduling
• Operations on Processes
• Threads
• Cooperating Processes
• Inter-process Communication
• Program counter
• Next instruction
• Stack
• Local variables
• Return addresses
• Method parameters
• Data section
• Global variables
© Copyright Information Technology Institute - 2022 6
Process State
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 - 2022 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 - 2022 16
Schedulers
• Process Creation
• Process Termination
* Process resources
• CPU time
• Memory
• Files
• I/O devices
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 - 2022 23
Process Creation Cont’d
• Execution
• Parent and children execute concurrently.
• Parent waits until children terminate.
© Copyright Information Technology Institute - 2022 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.
• Benefits:
1. Responsiveness
2. Resource sharing
3. Economy
• Many-to-One Model:
• One-to-one Model:
• Many-to-Many Model:
• Multiplexes many user-level threads to a smaller or
equal number of kernel threads.
• Thread-Specific Data
• Each thread might need its own copy of certain data in some circumstances.
• 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 - 2022 37
Synchronization