Chapter 5 Flashcards
what is a cooperating process
it can affect or be affected by other processes executing in the system
define race condition
several processes access and manipulate the same data concurrency and the outcome of the execution depends on the particular order in which the action takes place
what is a way to prevent race condition
process to be synchronized
a solution to the critical-section must satisfy what 3 requirements
- mutual exclusion
- progress
- bounded waiting
define Peterson’s solution
restricted to two processes that alternate execution between their critical sections and remainder sections
what should be used to see if a process is ready to enter its critical section
flag array
define locking
protecting critical regions through the use of locks
define mutex locks
mutual exclusion locks, simplest of synchronization tools, mutex lock has a boolean variable available whose value indicates if the lock is available or not
atomic process when lock is available
call to acquire() lock before entering a critical section, release() lock when it exits the critical section
define spinlock
the process spins while waiting for lock to become available, they are useful because context switch is not required
define busy waiting
wastes CPU cycles that could’ve been put to use by other processes
define semaphores
integer variable that is accessed through only 2 atomic operations: wait() and signal()
define counting semaphores
unrestricted domain
define binary semaphore
range between 0 and 1, behaves similarly to mutex locks
expand on the use of semaphores to count instances
- goes up when releasing a resource signal()
- goes down when using resource wait()
what keyword to synchronize semaphores
synch
expand how semaphores work
when a process executes a wait() operation and finds a semaphore value is not positive, it must wait. but instead of busy waiting, process can block itself. block operation places a process into a waiting queue and state of process is switched to waiting state. then the control is transferred to CPU scheduler. the waiting state is then restarted by wakeup() operation and it goes to ready state
define deadlocks
2 or more processes waiting indefinitely for an event that can be caused by only one of the waiting processes
define starvation
also known as indefinite blocking, it is a situation in which processes wait indefinitely within the semaphore
define priority inversion
scheduling problem when lower priority process holds a lock needed by higher priority process. solved by priority-inheritance protocol
what is the dining philosophers problem
need to allocate several resources among several processes in a dead-lock free and starvation-free manner
what is the difference between deadlocks and starvation
you can have starvation without deadlock.
what is the type of error caused by using semaphores incorrectly
timing errors. need to do wait() and then signal(). no other combination of the methods work
define monitor type
ADT, encapsulates data with a set of functions to operate on that data, includes a set of programmer-defined operations that are provided with mutual exclusion within the monitor
how to invoke wait() operation of condition x
x.wait();
what are the 2 processes that can continue execution in monitor usage
- signal and wait
2. signal and continue