DEV Community

Calzy
Calzy

Posted on

Question and Answer

Mutual Exclusion

Definition
A mutual exclusion (mutex) is a software object that stops several users from accessing a shared resource at the same time.

How to handle

  1. Use Token based algorithm, where a unique token is shared among all the sites.
  2. Non-token based approach, where a site communicates with other sites in order to determine which sites should execute critical section next.
  3. Quorum based approach. Instead of requesting permission to execute the critical section from all other sites, each site requests only a subset of sites which is called a quorum.

Deadlock

Definition
A deadlock occurs when a collection of processes is stalled because one process is holding a resource and waiting for another resource to be acquired by another process.

How to handle

  1. Prevention, prevent it from happening.
  2. Avoidance, use resource allocation algorithms.
  3. Detection and Recovery, examine the state of the system to identify if a deadlock has occurred.
  4. Timeouts, ensure that a process does not remain blocked indefinitely.

Starvation

Definition
Starvation is an issue that happens when high priority processes continue to run while low priority processes are halted indefinitely.

How to handle

  1. A freelancing manager should be in charge of CPU resource allocation to guarantee that resources are distributed evenly.
  2. Starvation can develop as a result of random process technique selection.
  3. To minimize famine, process aging criteria should be considered while allocating resources.
  4. To deal with famine, a scheduling method with a priority queue might be utilized.

Data Coherence

Definition
Data coherence encompasses both uniformity across shared resource data and logical links and completeness inside and between data sets.

How to handle

  1. Cache coherence protocols are used to ensure that all processors have the same value of a shared variable by maintaining consistency between cached copies of the variable across all processors.
  2. Memory barriers or synchronization instructions are used to ensure that changes made to a shared variable are visible to all processors by flushing any cached values and updating main memory.
  3. Locking or semaphores can be used to ensure that only one thread can modify a shared variable at a time, preventing race conditions and ensuring consistency.

Top comments (0)