Concurrency Modern OS central themes n Multiprogramming the

  • Slides: 11
Download presentation
Concurrency

Concurrency

Modern OS central themes n Multiprogramming "the management of multiple processes within a single

Modern OS central themes n Multiprogramming "the management of multiple processes within a single computer system" n Distributed processing "the management of multiple processes executing on multiple, distributed computer systems" Fundamental to both themes is concurrency

The concept of concurrency Processes are concurrent if they exist at the same time

The concept of concurrency Processes are concurrent if they exist at the same time n Processes that are either interleaved or overlapped in time to yield the appearance of simultaneous execution n P 1 P 2 P 3 time

A simple example n A program to provide character echo: input character from keyboard

A simple example n A program to provide character echo: input character from keyboard and output character on display repeat parbegin out: = in; output (out, display); input (in, keyboard) parend This program will work or not depending on the sequence the concurrent operations (copy is wrong) take place

How to implement concurrency n Programming language structures and mechanisms – n most programs

How to implement concurrency n Programming language structures and mechanisms – n most programs can be decomposed in at least three processes: input, process, output Operating systems structures and mechanisms process interaction – mutual exclusion –

Process Interaction Degree of Awareness Relationship Influence one process has on another Control problems

Process Interaction Degree of Awareness Relationship Influence one process has on another Control problems unaware competition results idependent mutual exclusion timing may be affected deadlock (renewable) starvation indirectly aware cooperation- sharing results may depend mutual exclusion timing may be affected deadlock (renewable) starvation coherence directly aware cooperationcommunication results may depend deadlock (consumable) timing may be affected starvation

Competition for resources n Mutual exclusion critical resources (nonsharable) – a process manages each

Competition for resources n Mutual exclusion critical resources (nonsharable) – a process manages each critical resource – n Deadlock a process is holding a critical resource (c 1) and waiting for another critical resource (c 2) – another process is holding (c 2) and waiting for (c 1) – n Starvation – one process is never granted access to a critical resource for other processes always get higher priority (and access) to the critical resource

Mutual exclusion requirements only one process at a time is allowed access to a

Mutual exclusion requirements only one process at a time is allowed access to a critical resource n a process that halts in a noncritical section should not affect others n a process should not be allowed to deadlock or starve n no delays should occur when a process requires a critical resource no others are using n a process remains in its critical section for a finite time only Technical: Dekker and Peterson algorithms, n

Monitors " a concurrency construct that contains both the data and procedures to perform

Monitors " a concurrency construct that contains both the data and procedures to perform allocation of a particular serially reusable shared resource or group of resources" n only one process is allowed to enter the monitor n if a process calls the monitor and a resource is already allocated the monitor calls wait (outside of monitor) n when a process releases a resource the monitor calls signal (and grants the resource to a process waiting for it) n it gives priority to waiting versus new n

Deadlock "the permanent blocking of a set of processes that either compete for systems

Deadlock "the permanent blocking of a set of processes that either compete for systems resources or communicate with each other" n resources n reusable (not depleted with use) – consumable (produced and consumed) – n conditions for deadlock mutual exclusion – hold-and-wait – no preemption – circular wait (deadly embrace) –

Deadlock management Principle Resource allocation schemas policy advantages disadvantages Prevention conservative request all processes

Deadlock management Principle Resource allocation schemas policy advantages disadvantages Prevention conservative request all processes with inefficient, delays resources at once single burst of process initiation activity preemption resources whose preempts more than state can be saved necessary, and restored easily needs to be restarted resource problem solved by ordering design preempts without need Detection very liberal invoked periodically does not delay to test deadlock process initiation preemption losses Avoidance midway between conservative and liberal search to find at no preemption least one safe path needed resources must be known, long blockings