Home | Projects | Notes > Operating Systems > Principles of Concurrency

Principles of Concurrency

 

Introduction

 

 

Process Interaction

 

Requirements for Mutual Exclusion

  1. Mutual exclusion must be enforced - only one process at a time is allowed into its critical section, among all processes that have critical sections for the same resource or shared object.

  2. A process that halts in its noncritical section must do so without interfering with other processes.

  3. It must not be possible for a process requiring access to a critical section to be delayed indefinitely - no deadlock or starvation.

  4. A process must not be denied or delayed access to a critical section when no other processes are using.

  5. No assumptions are made about relative process speeds or number of processors.

  6. A process remains inside its critical section for a finite amount of time only.

 

How does the OS Enforce Mutual Exclusion?

  1. Disabling interrupts (hardware way)

    Lowest-level method of enforcing the mutual exclusion

  2. Atomic operations (hardware primitive constructs)

    • Test-and-set instruction

    • Compare-and-swap instruction

  3. Semaphores (objects provided by the OS for the programmers to use)

    Higher-level than the hardware atomic operations

    • Binary semaphores

    • Counting semaphores

  4. Monitors

    Even higher-level object than the semaphores.

    Programming languages build monitors using the semaphores and locks that operating systems provide. (c.f., All objects in Java are very primitive monitors)

  5. Message passing

    Highest-level method of enforcing the mutual exclusion.

    A process has to wait (in blocked state) until it receives the message, etc.

See Mutual Exclusion - Software Emulation for software emulation of locks, which does not involve the OS.

 

 

References

Stallings, W. (2018). Operating Systems: Internals and Design Principles (9th ed.). Pearson Education, Inc.