Chapter 5 - Concurrency, Mutual Exclusion, and Synchronization

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/61

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:41 PM on 3/26/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

62 Terms

1
New cards

Operating System design is concerned with the management of what?

Processes and Threads

2
New cards

What is Multiprogramming?

The management of multiple processes within a uniprocessor system

3
New cards

What is Multiprocessing?

The management of multiple processes within a multiprocessor

4
New cards

What is Distributed Processing?

The management of multiple processes executing on multiple distributed computer systems.

5
New cards

What three contexts does concurrency arise?

  • Multiple Applications

  • Structured Applications

  • Operating System Structure

6
New cards

1st context of Concurrency - Multiple Applications:

Invented to allow processing time to be dynamically shared among a number of active applications

7
New cards

2nd context of Concurrency - Structured Applications:

An extension of the principles of modular design and structured programming, some applications can be effectively programmed as a set of concurrent processes.

8
New cards

3rd context of Concurrency - Operating System Structure

Operating Systems themselves implemented as a set of processes or threads.

9
New cards

What is mutual exclusion?

The requirement that when one process is in a critical section that accesses shared resources, no other process may be in a critical section that accesses any of those shared resources

10
New cards

Principals of Concurrency - Interleaving:

The processor acts like it is running multiple tasks at once by rapidly switching between them, often used in single-core systems

11
New cards

Principals of Concurrency - Overlapping

Different tasks genuinely run at the same time, particularly on multicore processors, or I/O operations occur concurrently within CPU processing.

12
New cards

What are the main problems with Interleaving and Overlapping?

Race conditions, deadlocks, and starvation are all common, the relative speed of execution of processes cannot be predicted

13
New cards

In a uniprocessor, what happens with processes?

The relative speed of execution of processes cannot be predicted.

14
New cards

What is concurrency?

The capability of an OS to run more than one task at the same time.

15
New cards

What are the difficulties of concurrency?

  • Sharing of global resources

  • Difficult for the OS to manage the allocation of resources optimally

  • Difficult to locate programming errors as results are not deterministic and reproducible.

16
New cards

What is a race condition?

A situation in which multiple threads or processes read and write a shared data item and the final result depends on the relative timing of their execution. THINK THE ATM EXAMPLE

17
New cards

What are the concerns raised in OS Concurrency?

The OS must:

  • Be able to keep track of various processes

  • Allocate and de-allocate resources for each active process

  • protect the data and physical resources of each process against interference by other processes

  • ensure that the processes and output are independent of the processing speed

18
New cards

When processes are unaware of each other, what do they do?

Compete

19
New cards

When processes are indirectly aware of each other, what do they do?

Cooperate by Sharing

20
New cards

When processes are directly aware of each other, what do they do?

Cooperate by communication

21
New cards

Concurrent processes come into conflict when they?

Are competing for the use of the same resource.

22
New cards

In the case of competing processes three control problems must be faced:

  • The need for mutual exclusion

  • Deadlock

  • Starvation

23
New cards

What are the requirements for mutual exclusion?

  • It must be enforced

  • A process that halts must do so without interfering with other processes

  • No deadlock or starvation

  • A process must not be denied access to the critical section when it is empty

  • No assumptions are made about the process speed or number of processes

  • A process remains inside its critical section for a finite time

24
New cards

What are the disadvantages of disabling interrupts to guarantee mutual exclusion?

The efficiency of the execution could be noticeably downgraded and it doesn’t work in a multiprocessor architecture

25
New cards

What are the two major Special Machine Instructions for Mutual Exclusion

Compare and Swap

26
New cards

What are the advantages of Special Machine Instruction?

  • Applicable to any number of processes on either a single processor or multiple processors sharing Main Memory

  • Simple and easy to verify

  • It can be used to support multiple critical sections; each critical section can be defined by its own variable

27
New cards

What are the disadvantages of Special Machine Instruction?

  • Busy-waiting is employed; while a processes is waiting for the critical section it consumed processor time

  • Starvation is possible with more than one process waiting

  • Deadlock is possible

28
New cards

What is a 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

29
New cards

Semaphore Initialize:

May be initialized to a nonnegative integer value

30
New cards

Semaphore Decrement:

The semWait operation decrements the value (lock)

31
New cards

Semaphore Increment

The semSignal operation increments the value (unlock)

32
New cards

Consequences of Semaphores

  • There is no way to know before a process decrements a semaphore whether or not it will block.

  • There is no way to know which process will continue immediately on a uniprocessor system when two processes are running concurrently

  • When you signal a semaphore, you don't know whether another process is waiting, so the number of unblocked processes may be zero or one.

33
New cards

What is a Strong Semaphore?

The process that has been blocked the longest is released from the queue first (no starvation)

34
New cards

What is a weak Semaphore?

The order in which processes are removed from the queue is not specified (Can have starvation)

35
New cards

What is the producer/consumer problem?

One or more producers are generating data and placing them in a buffer

A single consumer is taking items out of the buffer one at a time

Only one producer or consumer may access the buffer at any one time
The problem is that you must ensure the producer cannot add data when the buffer is full, and the consumer can’t remove from an empty buffer

36
New cards

How does one implement Semaphores?

The semWait and semSignal operations must be implemented as atomic primitives.

They can be implemented in hardware or firmware

Software schemes like Dekker’s or Peterson’s algorithms can also be used

Hardware-supported schemes for mutual exclusion also exist.

37
New cards

What are monitors?

Programming language constructs that provide the functionality of Semaphores while also being easier to control. They are software modules consisting of one or more procedures, an initialization sequence, and local data

38
New cards

Characteristics of Monitors:

  • Local data variables are accessible only by the monitors procedures, and not by any external procedure

  • Process enters monitor by invoking one of its procedures

  • Only one process may be executing in the monitor at a time

39
New cards

How is Synchronization achieved in Monitors?

The use the condition variables only accessible by the monitor: cwait and csignal

40
New cards

What makes Monitors primarily different from Semaphores?

The monitor itself enforces mutual exclusion, not the programmer.

41
New cards

When processes interact with one another, what fundamental requirements must be satisfied?

Synchronization (To enforce mutual exclusion) and Communication (To exchange information)

42
New cards

What is Message Passing?

An approach to provide Synchronization and Communication using a pair of primitives: send (destination, message) and receive (source, message)

A process sends information in the form of a message to another process designated by a destination

A process receives this information using the receive primitive

43
New cards

Communication of a message between two processes implies what?

Synchronization between the two

44
New cards

The receiver cannot receive a message until what?

It has been sent by another process

45
New cards

When a receive primitive is executed in a process, what are the two possibilities?

  • If there is no sent, waiting message, the process is blocked until a message arrives or the process continues to executing, abandoning the attempt to receive

  • If a message has been previously sent, the message is received and the execution continues

46
New cards

What are Blocking send and receive?

Both sender and receiver are blocked until the message is delivered, allowing for tight synchronization. Sometimes called a rendezvous

47
New cards

In a nonblocking send with a blocking receive:

  • Sender continues on but receiver is blocked until the requested message arrives

  • Most useful combination

  • Sends one or more messages to a variety of destinations as quickly as possible

  • Example — A service process that exist to provide a service or resource to other processes

48
New cards

In a Nonblocking send with a nonblocking receive

Neither party is required to wait

49
New cards

What is addressing?

Schemes for specifying processes in send and receive primitives. Fall into two categories: Direct and Indirect

50
New cards

What is Direct Addressing?

  • Send primitive includes a specific identifying of the destination process.

  • Receive primitive can be handled by either requiring that the process explicitly designate a sending process, or by implicit addressing when it is impossible to specify the anticipated source process

51
New cards

What is Indirect Addressing?

Messages are sent to a shared data structure consisting of queues that can temporarily hold messages. These queues are referred to a mailboxes.

One process sends a message to the mailbox and the other process picks up the message from the mailbox

Allows for greater flexibility in the use of messages

52
New cards

What is the Readers/Writers problem?

A data area is shared among many processes, where some only read the data area, and some only write to the data area. In this case, 3 conditions must be satisfied:

  1. Any number of readers may simultaneously read the file

  2. Only one writer at a time may write to the file

  3. If a writer is writing to the file, no reader may read it.

53
New cards

What is a race condition in concurrent processing?

A race condition occurs when multiple processes read/write shared data such that the final result depends on the unpredictable interleaving of their execution.

54
New cards

Why is mutual exclusion necessary?

To ensure only one process accesses a critical section at a time, preventing inconsistent or corrupted shared data.

55
New cards

What are the key requirements for a correct mutual exclusion mechanism?

Enforced exclusivity, no deadlock, no starvation, no assumptions about speed/number of processors, halted processes don't interfere, and finite critical-section time

56
New cards

How does a semaphore enforce synchronization?

semWait decrements and may block a process; semSignal increments and may unblock a waiting process, controlling access to shared resources.

57
New cards

What is the difference between strong and weak semaphores?

Strong semaphores unblock processes in FIFO order, preventing starvation; weak semaphores do not specify unblocking order.

58
New cards

Why can busy waiting be problematic in hardware-based mutual exclusion?

Because a process waiting for entry still consumes CPU time, causing inefficiency and potential deadlock/starvation.

59
New cards

What is the purpose of condition variables in monitors?

They allow a process to block inside a monitor until a condition is satisfied, using cwait and csignal for controlled synchronization.

60
New cards

How does message passing support mutual exclusion?

Processes use a mailbox as a token: receiving a message grants access to the critical section, and sending it back releases the resource.

61
New cards

What problem does the bounded-buffer producer/consumer solution address?

It ensures producers don’t add to a full buffer and consumers don’t remove from an empty buffer while coordinating buffer access safely.

62
New cards

What conditions define the readers/writers synchronization problem?

Any number of readers may read simultaneously, but only one writer may write, and no reader may read while a writer writes.

Explore top flashcards

flashcards
Ser Vocabulary
58
Updated 1163d ago
0.0(0)
flashcards
Psychology AOS 1 - Chapter 2
78
Updated 262d ago
0.0(0)
flashcards
AP Bio Unit 1
46
Updated 932d ago
0.0(0)
flashcards
AP Bio 8a Vocab
20
Updated 939d ago
0.0(0)
flashcards
SAT Vocab Final
150
Updated 1048d ago
0.0(0)
flashcards
ID cells w/ pictures
25
Updated 583d ago
0.0(0)
flashcards
7 Habits & 4 Atomic Unit
20
Updated 837d ago
0.0(0)
flashcards
Ser Vocabulary
58
Updated 1163d ago
0.0(0)
flashcards
Psychology AOS 1 - Chapter 2
78
Updated 262d ago
0.0(0)
flashcards
AP Bio Unit 1
46
Updated 932d ago
0.0(0)
flashcards
AP Bio 8a Vocab
20
Updated 939d ago
0.0(0)
flashcards
SAT Vocab Final
150
Updated 1048d ago
0.0(0)
flashcards
ID cells w/ pictures
25
Updated 583d ago
0.0(0)
flashcards
7 Habits & 4 Atomic Unit
20
Updated 837d ago
0.0(0)