View on GitHub

Notes

reference notes

Basically we will get to know more about PROCESS

In the computer there are many PROCESS. Each…need RESOURCES to finish!

MUTUAL EXCLUSION is a method to ensure each PROCESS get these RESOURCES

We will get to know how OS provide MUTUAL EXCLUSIVITY to PROCESSES

DEFINITION AND PRINCIPLES OF CONCURRENCY AND MUTUAL EXCLUSION (ME)

Concurrency

a property of a system in which several process are executing simultaneously, and potentially interacting with each other (i.e. in using the resources)

Key Terms

Basic characteristic of a multiprogramming System

The relative speed of execution of processes depends on :

  1. activities of other processes
  2. the way the OS handles interrupts
  3. scheduling policies of the OS

Difficulties in multiprogramming systems

  1. Sharing of global resources - e.g. Location in memory that is used for input and output buffer
  2. OS need to optimally managing the allocation of resources - no deadlock and no starvation
  3. Locating programming errors (results are not deterministic and reproducible)

Design and management issues raised by the existence of concurrency

The OS must:

  1. Be able to keep track of various processes
  2. Allocate and de-allocate resources for each active process
  3. Protect the data and physical resources of each process against interference by other processes
  4. Ensure that the processes and outputs are independent of the processing speed but relative to the speed of other concurrent processes

Reasons for conflict

Concurrent processes come into conflict when they are competing for use of the same resource. for example: I/O devices, memory, processor time, clock.

As a result of competing process, THREE CONTROL PROBLEMS must be managed:

  1. Need for mutual exclusion
  2. Deadlock
  3. Starvation

PROCESS INTERACTION CATEGORIES

1. UNAWARE OF EACH OTHER

These are independent processes that are not intended to work together. Each doing its own thing Each requiring resource

OS needs to be concerned about competition for resources

Relationship with other process: Resource Competition

Example: Different program just competing for resources

Potential control problems:

2. INDIRECTLY AWARE OF EACH OTHER

These processes are not necessarily aware of each other by their respective process IDs but they share access to some object, such as an I/O buffer.

Relationship with other process: Cooperation by sharing resources

Example: Sharing resources such as i/o buffer

Potential control problems:

3. DIRECTLY AWARE OF EACH OTHER

These processes that are able to communicate with each other by process ID and are designed to work jointly on some activity.

Such processes exhibit cooperation

Relationship with other process: Cooperation by communication

Example: Designed from the start to work together

Potential control problems:

Mutual Exclusion

A requirement of ensuring that no two concurrent processes are in their critical section at the same time.

It is a requirement that prevents simultaneous access to a shared resource used in concurrency control and to prevent race conditions.

Requirements for Mutual Exclusion

  1. Must be enforced
  2. A halted process must NOT interfere with other processes
  3. Each process will get its turn eventually (no deadlock / starvation)
  4. A process must be given access to a critical section when there is no other process using it
  5. No assumptions are made about relative process speeds or number of processes
  6. A process remains inside its critical section for a finite time only (limited time)

Hardware, Software and Programming Language Support for Mutual Exclusion

Satisfying the requirements of ME

3 Approaches:

Software Solutions

Hardware Support

  1. Interrupt Disabling

In uniprocessor systems, disabling interrupts guarantees mutual exclusion.

Disadvantages:

  1. Special Machine Instructions

Several machine instruction that carry out two actions atomically. such as reading and writing or reading and testing.

Automatically meaning the instructions are performed in single step that cannot be interrupted.

Preformed in a single instruction cycle.

Not subject to interference from other processes.

Advantages Disadvantages
Applicable to any number of processes on either a single or multiple processor sharing main memory Busy-waiting is employed, thus while a process is waiting for access to a critical section it continues to consume processor time
Simple and easy to verify Starvation is possible when a process leaves a critical section and more than one process is waiting
It can be used to support multiple critical sections. Each critical section can be verify by it owns variable. Deadlock is possible

Software Support for ME: Semaphore

An integer value used for signaling among processes. Only three operations may be performed on a semaphore, all of which are atomic: initialize, decrement, and increment. The decrement operation may result in the blocking of a process, and the increment operation may result in the unblocking of a process. Also known as a counting semaphore or a general semaphore.

Fundamental Principle: Two or more processes can cooperate by means of simple signals,

Any complex coordination requirement can be satisfied by the appropriate structure of signals.

There is no way to inspect or manipulate semaphores other than these three operations:

A variable that has an integer value upon which only three operations are defined: 1) May be initialized to a nonnegative integer value (0 and above) 2) The semWait operation decrements the value

We explain these operations as follows.

To begin, the semaphore has a zero or positive value. If the value is positive, that value equals the number of processes that can issue a wait and immediately continue to execute. If the value is zero, either by initialization or because a number of processes equal to the initial semaphore value have issued a wait, the next process to issue a wait is blocked, and the semaphore value goes negative. Each subsequent wait drives the semaphore value further into minus territory. The negative value equals the number of processes waiting to be unblocked. Each signal unblocks one of the waiting processes when the semaphore value is negative.