Lecture 10: Synchronization 1 Flashcards

1
Q

Process/Thread Synchronization

A
  • For processes, threads to communicate, require shared data access
  • Shared data access in unpredictable order determined by scheduler can lead to data inconsistencies and undesirable process / thread behaviors. Synchronization prevents that.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Processes

A

IPC, shared files, …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Threads

A

Shared memory communication

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Race Condition

A

Outcome of thread execution depends on timing of threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Synchronization

A

Use of atomic (i.e.: uninterruptible) operations to ensure correct cooperation amongst threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Mutual Exclusion

A
  • Ensuring that only one thread does a particular thing
    (e. g.: Go to the store and buy milk) at a time
  • one thread’s execution excludes the other
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Critical Section

A
  • Piece of code that only one thread can execute at any time
    (i. e.: Only 1 thread at a time gets into this code)

-Typically: Code that reads, writes shared variables, files,…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Lock

A

-Construct that prevents someone from doing something

e. g.: 1. Lock before entering critical section
2. Unlock when leaving critical section
- wait if locked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Starvation

A

-Occurs when 1 or more threads never gets access to critical section

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Critical Sections Problem

A

-Ensure that only one thread executes its critical section at a time (avoid race condition)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Producer-Consumer Problem

A

Producer produces objects into shared buffer
• Consumer consumes objects from shared buffer
• Producer, consumer run as separate threads
• Must ensure:
1. Consumer doesn’t remove from empty buffer
2. Producer doesn’t insert into full buffer (bounded-buffer only)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Critical Sections Problem Goals of Solution

A
  1. Mutual exclusion
    no more than 1 process in its critical section at a time
  2. Progress: No thread outside of its critical section should block other threads
  3. Bounded waiting: Must be a bound on number of times other threads allowed to enter their critical sections after thread has made request to enter its critical section and before request granted
    • assume each thread executes at non-zero speed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly