Chapter 23 Flashcards
What is semaphore
Semaphore is an integer variable that can be accessed by 2 atomic operations.
What block() operation do
block() suspends the process that invokes it
What wakeup() operation do
wakeup(P) resumes the execution of a blocked process P.
When critical sections are small which one is better
- busy-waiting
- queue-waiting
busy-waiting
When critical sections are long which one is better
- busy-waiting
- queue-waiting
queue-waiting
Could we have semaphorse based solution for process synchronization
Yes
If programmer mistakenly use semaphore wait operation, what will happen
Then there will be 3 general problems
- Mutual exclusion violation
- Infinite blocking of some process (starvation)
- Deadlocks (2 processes waiting for each other to execute and no one execute)
What are 2 types of deadlock
- Traffic deadlock
2. one-way bridge-crossing
Why programming error occurs in semaphore
Due to tandem use of wait() and signal() operations
What is the solution of programming errors in semaphore
Make wait() and signal() operations as programming construct. Then programmer do not need to implement it.
What are 2 examples of programming constructs for semaphor
- Critical regions
2. Monitors
What are types of semaphores
- Counting semaphore
2. Binary semaphore
What are binary semaphore
Its integer value can not be >1. They are simpler to implement. Values can be negative.
What are counting semaphore
Integer value can range over an unrestricted integer domain.