Question

In: Computer Science

2. Which of the generic architectures considered in lectures is most susceptible to race conditions. Explain...

2. Which of the generic architectures considered in lectures is most susceptible to race conditions. Explain your reasoning -- why do you believe that your chosen architecture is most susceptible?

Solutions

Expert Solution

Race Conditions: A race condition is an abnormal situation that occurs when a system attempts to perform more than one operations at the same time.

The race condition could be in the form of system, processes, threads, etc.

The generic architecture would be writing by more than one systems, processes, threads at a time.

For two processes - there are 4 possible architectures

1. Read by Process 1, Read by Process 2

2. Read by Process 1, Write by Process 2

3. Write by Process 1, Read by Process 2

4. Write by Process 1, Write by Process 2


Let's take a simple example to understand why writing by more than one processes is the most susceptible to the race condition.

// Example of a variable

/*

x = 2;

// Any process is modifying the value of x here.

if ( x == 2 ) {

x = 10;

}

'''

There are some more instructions to the program accessing variable x.

'''

*/

Suppose, there are two processes accessing the above program - named process A and process B. The program is sharing data among processes.

for both processes, they should get 10 as the value of x after if condition.

But suppose, A is accessing it at the first so A should get 10 and so do B is but when B is trying to access the data, there's a process C who is modifying the value of x before B gets to the if condition, So B won't enter in the if condition and B would get 2 as the value x.

Since A and B needed to get 10 as the value, but another process C writes the value of x before B writes it so there would be a race condition.

I have chosen Write-Write situation because of multiple processes trying to modify the value of x at the same time. If only one process is writing/modifying the value of x at one time, then there won't be any conflict because all of the processes except the one who is modifying x, would get the updated value of x.

The above example would get you a good idea of race condition. Another example would be `two people are trying to book the same ticket at the same time`.
So you should use any locking mechanism for preventing them for the race condition such as semaphores, mutual exclusion, etc.


Related Solutions

Using fundamental thermodynamics, and ignoring reaction kinetics, explain which of the following materials is most susceptible...
Using fundamental thermodynamics, and ignoring reaction kinetics, explain which of the following materials is most susceptible to corrosion in fully aerated (O2 saturated) seawater (pH = 6.5) -- aluminum metal, iron metal, glass (silicon dioxide), or gold.
Predators and prey are often considered to be locked in an evolutionary arms race in which...
Predators and prey are often considered to be locked in an evolutionary arms race in which the prey are always one step ahead of the predators. Explain why prey should typically evolve more quickly than predators. You should provide at least 3 reasons with a brief explanation.
Explain the five conditions necessary for an act to be considered fraudulent.
Explain the five conditions necessary for an act to be considered fraudulent.
explain why being an ethical leader is difficult. what aspects of leadership are most susceptible to...
explain why being an ethical leader is difficult. what aspects of leadership are most susceptible to unethical acts
1. Which of the following statements is TRUE regarding transcription in Eukaryotes? pre-mRNAs are most susceptible...
1. Which of the following statements is TRUE regarding transcription in Eukaryotes? pre-mRNAs are most susceptible to degradation in the nucleus after addition of the poly(A) tail The template strand of DNA is utilized by RNA polymerase II to transcribe a gene The entire mRNA molecule produced during transcription is ultimately translated into protein dNTPs are utilized by RNA polymerase II during the elongation phase of transcription Mutations in the Kozak sequence will result in inability of RNA polymerase II...
An investment would be considered a good prospect under which of the following conditions?
An investment would be considered a good prospect under which of the following conditions?
Which of the following generic strategies is the most difficult to implement and why? Cite concrete...
Which of the following generic strategies is the most difficult to implement and why? Cite concrete examples. Overall low-cost provider strategy; broad differentiation strategy; focused low-cost strategy; focused differentiation strategy; best-cost provider strategy
In Chapter 5, we discussed possible race conditions on various kernel data structures. Most scheduling algorithms...
In Chapter 5, we discussed possible race conditions on various kernel data structures. Most scheduling algorithms maintain a run queue, whichlistsprocesseseligibletorunonaprocessor.Onmulticoresystems, there are two general options: (1) each processing core has its own run queue, or (2) a single run queue is shared by all processing cores. What are the advantagesand disadvantages of each of these approaches?
Which conditions produced the most mold growth? Which were the slowest?
Which conditions produced the most mold growth? Which were the slowest?
1. Explain the pathophysiological conditions which necessitate the use of dialysis machine. 2. Explain the mechanism...
1. Explain the pathophysiological conditions which necessitate the use of dialysis machine. 2. Explain the mechanism underlying dialysis using a typical dialysis machine. 3. Explain the challenges involved in the use of the dialysis machine
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT