Synchronisation - Chapter 6
Needed to ensure orderly execution.
Critical section - this is the part of the process that is sensitive to multiple processes working at the same time
Mutual exclusion - when only one process can run the critical section at a time
Bounded waiting - number of processes that can run the critical section at a time
Non-preemptive - only one process runs at a time therefore, no other process will be running the critical section
Preemptive - multiple threads can be running at once, therefore, synchronisation is needed in especially in symmetric systems
Mutex
Require() - takes control of a critical section if free, or will spin until it is free (i.e. wont context switch)
Release() - sets the critical section to free
Semaphore
Same as mutex except you can have multiple threads running the critical section, up to a specified integer
only one thread at a time can change the semaphore
wait() - tries to acquire the semaphore, once acquired will decrease the semaphore value by one
signal() - releases the semaphore, once released will increase the semaphore value by one
Binary semaphores - are baso mutexes, max value = 1
Counting semaphores - are what we just discussed, max value = n
Deadlock
When one process A is waiting on another process B to complete a task before it can proceed, however, process B is also waiting on process A to complete a task before it can proceed.