1/15
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
what are race conidtions
when the output depends on the timing/interleaving of operations
processes can run concurrently
processes can be interrupted at any time
shared data can end up inconsistent
what is the critical section
any section of code that uses shared data; when one process is in its critical section, no other may be in its critical section
what are examples of code that can be found in the critical section
Changing common variables
Updating tables
Writing files
what is the general structure of a process
entry section
critical section
exit section
remainder section
what are the bad solutions of the critical section problem
disabling interrupts: impractical and can cause starvation, and too much control to users/developers
shared flags: one process can block unnecessarily even when critical section is free
what are the 3 requirements for a correct critical section problem solution
1, mutual exclusion: one process in critical section at a time
progress: if critical section is free, can’t postpone forever
bounded waiting: a bound must exist on how long a process can be forced to wait
what is peterson’s solution
use turn (whose turn it is) and flag[2] (who wants to enter)
what are the 3 hardware solutions to the critical section problem
memory barrier instructions:
hardware instructions
atomic variables
what are memory barrier instructions
instructions to force memory updates to all processors ensuring that all threads use the correct data
what are hardware instructions
instructions guaranteed to function atomically (uninterruptible)
what are atomic variables
variables with operations that use only atomic hardware instructionw
what are mutex locks
a user-friendly approach built by kernel developers for application developers to provide mutual exclusion; a boolean variable indicating if a lock is available or not
what do acquire() and release() do for mutex locks
acquire(): acquires the lock and enters the critical section
release() releases the lock and exits the critical section
what is busy-waiting
any process that wishes to enter its critical section must loop continuously white it waits
what are the two types of semphores
binary semaphore: integer value can range only between 0 and 1 (mutex)
counting semaphore: Integer value can range over an unrestricted domain
what do wait(S) and signal(S) do
wait(S) obtains a resource if available
signal(S) releases a resource
If the value of S reaches 0, then no resources are available and the call wait(S) will block until one becomes available