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

Lesson Two Process Management

Uploaded by

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

Lesson Two Process Management

Uploaded by

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

DEPARTMENT: ICT AND ENGINEERING

UNIT : OPERATING SYSTEM

COMPILED BY:

FREDRICK OCHIENG OKELLO

EMAIL: [email protected]

PHONE NO: 0700700763 / 0768663848

NOTES ARE RELEVANT TO THE

FOLLOWING COURSES:

DCS,DBIT,DIT,DSE
PROCESS MANAGEMENT

A process can be thought as a program in execution. It needs certain resources including CPU time

memory, file and I/O devices to accomplish its task.

The o/s is responsible for the following activities in connection with process management:

 Creation and deletion of both user and system processes

 Suspension and resumption of processes

 Provision of mechanism for process synchronization

 Provision of mechanism for process communication

 Provision for mechanism for deadlock handling.

Process Model

A process is more than a program. It includes current activity temporary data containing global value. A

program is a passive entity e.g. contents of a file stored on disk where as a process is an entity.

Process state

As a process executes, it changes state. The state of a process is defined in part by the current activity of

that process. It states may be:

i) New – process is being created

ii) Ready – waiting to be assigned to a processor

iii) Waiting – process waiting for some event to occur.

iv) Running – Instructions are being executed

v) Terminated – finished execution.


Diagram of process state

INTER-PROCESS COMMUNICATION

O/s must provide inter-process communication facility (IPC) which provides a mechanism to allow

processes to communicate and to synchronize their actions to prevent Race conditions (a condition where

several processes access and manipulate the same data concurrently and the outcome of the execution

depends on the particular order in which the access takes place).

To guard against this mechanisms are necessary to ensure that only one process at a time can be

manipulating the data. Some of this mechanisms / techniques include:


Critical Section Problem

It is a segment of code in which a process may be changing common variables, updating a table, writing a

file etc. Each process has its critical section while the other portion is referred to as Reminder section.

The important feature of the system is that when one has process is executing in its critical section no

other process is to be allowed to execute its critical section. Each process must request permission to enter

its critical section.

A solution to critical section problem must satisfy the following:

i) Mutual Exclusion – If one process is executing its critical section then no other process can be

executing in their critical section.

ii) Progress – If no process is executing in its critical section and there exists some processes that

wish to enter critical sections then those processes that are not executing in their remainder

section can be allowed.

i) Bounded Waiting – There must exist a bound on the number of times that other processes are

allowed to enter their critical sections after a process has made a request to enter its critical

section and before that request is granted (Prevents Bus waiting).

Busy waiting occurs when one process is being executed in its critical section and process 2 tests

to confirm if process 1 is through. It is only acceptable technique when the anticipated waits are

brief; otherwise it could waste CPU cycles.

Techniques used to handle Critical section problem

1. Semaphores

The fundamental principle is this: 2 or more processes can operate by means of simple signals, such that a

process can be forced to stop at a specified place until it has received a special signal.

Any complex coordinative requirement can be satisfied by the appropriate structure of signals.
For signaling special variables called semaphores are used: To transmit a signal via semaphores, a process

executes the primitive wait P(s); if the corresponding signal V(s) has not yet been transmitted the process

is suspended until transmission takes place.

To achieve the desired effect we can view the semaphore as a variable that has an integer value upon

which 3 operations are defined

a) A semaphore may be initialized to a non negative value

b) The wait operation decrements these semaphore value. If the value becomes negative the process

executing the wait is blocked.

c) The signal operation increments the semaphore value. If the value is not positive then a process is

blocked by await operation is unblocked

A binary semaphore accepts only 2 values 0 or 1. For both semaphore and binary semaphore a queue is

used to hold processes waiting on the semaphore.

A strong semaphore has a mechanism of removing processes from a queue e.g. FIFO policy.

A weak semaphore doesn’t specify the order in which processes are removed from the queue.

Example of implementation:

wait (S);

Critical Section

signal (S);
2. Message passing

Provides a means for co-operating processes to communicate when they are not using shared memory

environment. Processes generally send and receive messages by using system calls such as: send

(receiverprocess; message) or Receive (senderprocess; message).

A blocking send must wait for receiver to receive the message. A non blocking send enables the sender to

continue with other processing even if the receiver has not yet received the message. This requires

buffering mechanisms to hold messages until the receiver receives it.

Message passing can be flawless on some computers but in a distributed system it can be flawed or even

lost, thus acknowledgement protocols are used.

One complication in distributed systems with send / receive message passing is in naming processes

unambiguously so that send and receive calls references the proper process.

Process creation and destruction can be coordinated through some centralized naming mechanisms but

this can introduce considerable transmission overhead as individual machines request permission to use

new names.

3. Monitors

It is a high synchronization construct characterized by a set of programmer defined operations. It is made

of declarations of variables and bodies of procedures or functions that implement operations of a given

type. It cannot be used directly by the various processes; ensures that only one process at a time can be

active within a monitor.


Schematic view of a monitor
Processes desiring to enter the monitor when it is already in use must wait. This waiting is automatically

managed by the monitor. Data inside the monitor is accessible only to the process inside it. There is no

way for processes outside the monitor to access monitor data. This is called information hiding.
Event Counters

Introduced to enable process synchronization without use of mutual exclusion. . It keeps track of no of

occurrences of events of a particular class of related events. It is an integer counter that does not decrease.

Some operations will allow processes to reference event counts e.g. Advance (event Count), Read (event

count) and await (event count value).

Advance (E) –signals the occurrence of an event of the class of events represented by E by incrementing

event count E by 1.

Read (E) – obtains value of E; because Advance (E) operations may be occurring during Read (E) it is

only guaranteed that the value will be at least as great as E was before the read started.

Await (E) – blocks the process until the value of E becomes at least V; this avoids the need for busy

waiting.

Other techniques used include:

Using Peterson’s algorithm, Dekker’s algorithm and Bakery’s Algorithm

You might also like