0% found this document useful (0 votes)
10 views

OperatingSystemConcepts 4 Processes

This chapter discusses processes in operating systems. It defines a process as a program in execution. Processes go through different states like running, ready, waiting, and terminated. The operating system uses a process control block to manage processes and their related information. Process scheduling involves moving processes between ready, running, waiting, and other queues. Operations on processes include creation where a parent process spawns child processes, and termination where a process ends. Processes can also cooperate with each other through inter-process communication.

Uploaded by

Amira Bahaa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

OperatingSystemConcepts 4 Processes

This chapter discusses processes in operating systems. It defines a process as a program in execution. Processes go through different states like running, ready, waiting, and terminated. The operating system uses a process control block to manage processes and their related information. Process scheduling involves moving processes between ready, running, waiting, and other queues. Operations on processes include creation where a parent process spawns child processes, and termination where a process ends. Processes can also cooperate with each other through inter-process communication.

Uploaded by

Amira Bahaa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Information Technology Institute

Operating System Fundamentals

© Copyright Information Technology Institute - 2018


Chapter Four
PROCESSES

© Copyright Information Technology Institute - 2018 2


Table of Content

• Process Concept
• Process Scheduling
• Operations on Processes
• Cooperating Processes
• Inter-process Communication

© Copyright Information Technology Institute - 2018 3


PROCESS CONCEPT

© Copyright Information Technology Institute - 2018 4


Process Concept

• Process – a program in execution; process


execution must progress in sequential fashion.
• An operating system executes a variety of
programs:
• Batch system
• Time-shared systems

* Textbook uses the terms job and process almost


interchangeably

© Copyright Information Technology Institute - 2018 5


Process Contents
1
• Text section
• Program instructions

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)

© Copyright Information Technology Institute - 2018 7


Process State Cont’d

• As a process executes, it changes state


• new: The process is being created.
• running: Instructions are being executed.
• waiting: The process is waiting for some event to
occur.
• ready: The process is waiting to be assigned to a
processor.
• terminated: The process has finished execution.

© Copyright Information Technology Institute - 2018 8


Process Control Block (PCB)
os mno bymanage and track the process and its related info.

• Information associated with each process.


• Process state
• Program counter
• CPU registers
• CPU scheduling information
• Memory-management information
• Accounting information
• I/O status information
© Copyright Information Technology Institute - 2018 9
Process Control Block (PCB) Cont’d
Pointer Process state

Process number

Program counter

CPU registers

Memory management info

I/O status information

Accounting Information

© Copyright Information Technology Institute - 2018 10


CPU Switch From Process to
Process

© Copyright Information Technology Institute - 2018 11


PROCESS SCHEDULING

© Copyright Information Technology Institute - 2018 12


Process Scheduling

• 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.

* Process migration between the various queues


© Copyright Information Technology Institute - 2018 14
Ready Queue And Various I/O
Device Queues

© Copyright Information Technology Institute - 2018 15


Representation of Process
Scheduling
in
out
Ready queue CPU

I/O I/O queue I/O request

time slice
expired

child executes fork a child

wait for an
interrupt occurs
interrupt
© Copyright Information Technology Institute - 2018 16
Schedulers

• Long-term scheduler (or job scheduler)


• Selects which processes should be brought into
the ready queue. from different states.

• 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.

Here's what medium-term scheduling does:

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.

• Proper System performance


• Mix of CPU & I/O bound processes

• Improper system performance


• All processes are I/O bound
• All processes are CPU bound © Copyright Information Technology Institute - 2018 19
Context Switch

• When CPU switches to another process, the


system must save the state of the old process
and load the saved state for the new process.
• Context-switch time is overhead; the system
does no useful work while switching.
• Time dependent on hardware support.

© Copyright Information Technology Institute - 2018 20


OPERATIONS ON PROCESSES

© Copyright Information Technology Institute - 2018 21


Operations on Processes

• 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

• Parent process create children processes, which,


in turn create other processes, forming a tree of
processes.
• Resource sharing
• Parent and children share all resources.
• Children share subset of parent’s resources.

• 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.

© Copyright Information Technology Institute - 2018 25


Process Termination

• Process executes last statement and asks the operating


system to decide it (exit).
• Output data from child to parent.
• Process’ resources are de-allocated by operating system.
• Parent may terminate execution of children processes
(abort).
• Child has exceeded allocated resources.
• Task assigned to child is no longer required.
• Parent is exiting.
• Operating system does not allow child to continue if its parent
terminates.
• Cascading termination.
© Copyright Information Technology Institute - 2018 26
Cooperating Processes

• Independent process cannot affect or be affected


by the execution of another process.
• Cooperating process can affect or be affected by
the execution of another process
• Advantages of process cooperation
• Information sharing
• Computation speed-up
• Modularity
• Convenience
© Copyright Information Technology Institute - 2018 27
INTER-PROCESS
COMMUNICATION
© Copyright Information Technology Institute - 2018 28
Inter-process Communication

• Message Passing

• Shared Memory

* Synchronization

© Copyright Information Technology Institute - 2018 29


Message Passing

• 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

• Message passing may be either blocking or


non-blocking. wra b3d mstnyen b3d

• Blocking is considered synchronous


• Non-blocking is considered asynchronous
msh wra b3d , kol wa7ed bysend fl w2t ely y3gbo.

• send and receive primitives may be either


blocking or non-blocking.

© Copyright Information Technology Institute - 2018 31


© Copyright Information Technology Institute - 2018 32

You might also like