Chapter 6 OS - Synchronization

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
GameKnowt Play
New
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/26

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

27 Terms

1
New cards

Race condition

Situation where several processes access and manipulate the same data concurrently. Outcome depends on particular order in which access takes place

2
New cards

Critical section

Segment of code where a process may be accessing and updating data that is shared with at least one other process

3
New cards

Three requirements for a solution to the critical section problem

  1. Mutual exclusion - Only one process can execute in its critical section at a time

  2. Progress - If no progress is in its critical section, processes not in remainder sections can decide who enters next

  3. Bounded waiting - There is a limit on how many times other processes can enter their critical sections after a process request entry

4
New cards

Peterson’s Solution

Simple algorithm for two processes. Uses two shared variables to coordinate.

5
New cards

Two shared data items in Peterson’s solution

Int turn - indicates whose turn it is to enter critical section

boolean flag[2] - indicates if process is ready to enter its critical section

6
New cards

Peterson’s solutions does not work on modern architectures due to…

Modern processors and compilers reorder read and write operations that have no dependencies. 

7
New cards

Memory barrier(Memory fence)

Instruction that forces all loads and stores to be completed before any subsequent load or store operations are performed, ensuring memory modifications are visible to other processors

8
New cards

Test_and_set

Automatically sets boolean variable to true and returns original value, all as one uninterruptible operation

9
New cards

compare_and_swap

Automatically compare a value to expected value, if they match, updates it to a new value. It always returns original value.

10
New cards

Atomic variable

A variable that provides atomic operations on basic data types (integers,booleans) typically implemented using compare_and_swap operations

11
New cards

Mutex

Mutual exclusion

12
New cards

Two main operations of mutex lock

acquire() and release()

13
New cards

acquire() in mutex

Acquires the lock before entering critical section

14
New cards

Release() in mutex

Releases the lock when exiting critical section

15
New cards

What is a spinlock

A mutex lock where process “spins” or busy waits while waiting for the lock to become available, without needing a context switch

16
New cards

When are spin locks preferable to regular locks

On multi core systems when a lock will be held for a short duration( less than two context switches), they avoid the overhead of context switching

17
New cards

Lock contention

Lock contention is when a thread is blocked when trying to acquire it.

18
New cards

Semaphore

An integer variable accessed only through two atomic operations

19
New cards

Two atomic operations

  1. Wait()

  2. Signal()

20
New cards

Two types of semaphores

Binary and counting

21
New cards

Binary semaphores

Value ranges between 0 and 1 

22
New cards

Counting semaphores

Value ranges over an unrestricted domain

23
New cards

Wait() operation on a semaphore

Waits while S less then or = to 0( busy wait) then decrements S 

24
New cards

Signal() operation on semaphore

Increments the semaphore value S

25
New cards

Semaphores avoid busy waiting

Suspends processes that wait and places them in waiting queue, then using wakeup() to resume them when signal() is called

26
New cards

Monitors

An abstract data type that includes programmer defined operations with mutual exclusion within the monitor, encapsulating shared data and operations

27
New cards