OS Week 6

Cards (24)

  • Multi-Resource Banker’s Algorithm: Logically same as single-resource, using arrays to track multiple resources instead of simple counters
  • Message passing in C/C++ involves basic operations such as send(buff, len) and receive(buff, len) to define a protocol within the buffer.
  • Barriers in C/C++ are used to create synchronization points in a program named 'barriers'.
  • The classic IPC problem of Readers/Writers occurs when a database has no of processes accessing it concurrently (reading or writing).
  • Multiple readers can execute concurrently in the Readers/Writers problem, but only one writer can execute at a time.
  • Readers cannot be executing while writer is executing in the Readers/Writers problem.
  • Deadlock occurs when each process in a set is blocked on a resource held by another process in the set.
  • A deadlock with one process is possible – A process locks the same mutex twice without unlocking it.
  • Deadlocks are dependent on scheduling order.
  • The necessary and sufficient conditions for a deadlock include a mutex on a resource and hold & wait.
  • A break condition can eliminate a deadlock by eliminating the mutex or allowing pre-emption.
  • Deadlock recovery involves admitting the problem, periodically running a detection algorithm, and recovery may not always be simple.
  • Three states associated with deadlock avoidance are Safe, Unsafe, and Deadlock.
  • In the Safe State, deadlock can be avoided simply by delaying resource requests to lock its max number of resources, assuming resources are unlocked once process is done with them, and does not require all processes to have max set locked simultaneously.
  • In the Unsafe State, deadlock cannot be avoided merely by delaying requests, not all unsafe states result in deadlock, system can no longer keep processes out of deadlock, and process may or may not deadlock depending on allocation/release ordering.
  • Deadlock avoidance anticipates when deadlock can occur, blocks requests that may cause deadlock, considers all future potential resource requests, not just current request, typically only worst-case resource set is specified, and lock granting decisions aren’t made until lock is actually requested.
  • Resource lock must always be reclaimed.
  • The Safe State Algorithm augments resource allocation graph, adds 3rd edge type, ‘Process may block’ edge, goes from process → resource process may block on, similar to ‘blocked’ edge, and if granting resource requests will result in cycle in new allocation graph, don’t grant request.
  • While in the Safe State, resource requests are granted only if resulting state is also safe, allowing resource allocation order to dynamically adjust with program while still preventing deadlock.
  • Multi-Instance Resources may be many instances of identical resources for purpose of process, any instance is sufficient, and resource allocation graph changes slightly.
  • In the Multi-Resource Banker’s Algorithm, before granting request, ensure new state is a safe state, it can be a much slower algorithm, and it is performed for every allocation request.
  • If available resources are less than what process needs, system is deadlocked, and if available resources are enough to satisfy process, give process to those resources, run to completion and release resources, and repeat until all processes have completed.
  • Each resource in Multi-Instance Resources can have multiple instances, process isn’t blocked until all instances are locked, and resource reserved edges from instance to process.
  • The Deadlock State is when deadlock occurs.