Question

• Code where a process is changing shared data memory P1 X = X + 2; X 5 X = X + 3;

P1 needs to add 2 to X

P2 needs to add 3 to X

P1 reads X (5)

P2 reads X (5)

P1 adds 2 to X and stores 7

P2 adds 3 to X and stores 8

Should X be 7, 8 or 10?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The order of the reads and writes affects the value stored.
P1 and P2 both read the same value of X(5) since the reads occur before the writes and value of X remains unchanged. P1 writes X as 7 but since P2 stores the value of X after P1, the value stored in X by P1 will be overwritten by P2 and 8 will be stored.
So, the final value in X is 8.

Add a comment
Know the answer?
Add Answer to:
P1 needs to add 2 to X P2 needs to add 3 to X P1 reads...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • III. Consider a process that has been allocated 5 pages of memory: P1, P2, P3, P4, and P5. The process accesses these pages in the following order: P1 P2 P3 P4 P1 P2 P5 P1 P2 P3 P4 P5 (i) Illustrate...

    III. Consider a process that has been allocated 5 pages of memory: P1, P2, P3, P4, and P5. The process accesses these pages in the following order: P1 P2 P3 P4 P1 P2 P5 P1 P2 P3 P4 P5 (i) Illustrate Belady’s anomaly by precisely describing the execution of the FIFO page eviction algorithm in two cases: a) where the machine has 3 pages of physical memory, and b) where the machine has 4 pages of physical memory, and by...

  • Q3. In a (7,4) Hamming Code, three parity bits p1, p2, p3 are added to four...

    Q3. In a (7,4) Hamming Code, three parity bits p1, p2, p3 are added to four data bits dl, d2, d3, and d4, and the coverage of each parity bit is as shown in the table below: Bit position 2 3 4 5 6 7 Encoded data bits p1 p2 di p3 d2 d3 d4 da X p1 X X X x Parity bit coverage p2 х X X p3 X X X х 1) (3 pts) Assume even parity...

  • QUESTION 1 Process P1 waits on the condition x in the monitor M. Process P2 calls...

    QUESTION 1 Process P1 waits on the condition x in the monitor M. Process P2 calls x.signal() within a function defined in the same monitor M. What further scenario is possible? (Check all that apply.) Process P2 is suspended. Process P1 resumes the execution. Process P1 resumes the execution. Process P2 continues the execution. Process P2 continues the execution. Process P1 is nonetheless suspended until P2 leaves the monitor. The operation x.signal() fails. QUESTION 2 The following pseudocode fragment adds...

  • Two portfolios, P1 and P2, produce the following returns in years 1-5: Year P1 Return (%)...

    Two portfolios, P1 and P2, produce the following returns in years 1-5: Year P1 Return (%) P2 Return (%) 1 8 -10 2 3 -4 3 -6 4 4 7 -6 5 7 5 What is the mean annual return on a portfolio that is 70% invested in P1 and 30% invested in P2? Enter answer accurate to 2 decimal places

  • Part 2 Round Robin Scheduling Process Burst Time in Ms P1 4 P2 2 P3 1...

    Part 2 Round Robin Scheduling Process Burst Time in Ms P1 4 P2 2 P3 1 Calculate the average waiting time and turnaround time using round robin scheduling, where the time quantum q = 2 ms According to the Round Robin algorithm, the arrival of processes is shown in the following Gantt chart. P1 P2 P3 P1 P2 P3 P1 P2 P3 P1 0                 2                 4                  6                8                 10               12                14               15              16               18...

  • Need the process that how we get P2 P1 P4 P3 and waiting time please 1....

    Need the process that how we get P2 P1 P4 P3 and waiting time please 1. Draw a Gantt chart below similar to the ones from lecture that illustrates the execution of the processes using the shortest-job-first CPU scheduling algorithm. Process Arrival Burst | Time Time P. 7 ms 2 ms | P2 Oms 8 ms 11 ms 5 ms P4 4 ms 9 ms P2 P2 P4 P3 oms 8 10 19 24 | Using the chart you drew,...

  • Exercise 2 Let B= (Po, P1, P2) be the standard basis for P2 and B= (91,92,93)...

    Exercise 2 Let B= (Po, P1, P2) be the standard basis for P2 and B= (91,92,93) where: 91 = 1+2,92 = x+r2 and 43 = 2 + x + x2 1. Show that S is a basis for P2. 2. Find the transition matrix PsB 3. Find the transition matrix PB-5 4. Let u=3+ 2.c + 2.ra. Deduce the coordinate vector for u relative to S.

  • Burst Time Arrival Time P1 54 2 P2 12 3 P3 26 4 P4 16 5...

    Burst Time Arrival Time P1 54 2 P2 12 3 P3 26 4 P4 16 5 P5 8 6 P6 92 7 use SRTF (1) Gant chart (2) Waiting time and Turn around time for every process (3) Average WT and Average TAT

  • Consider the following expenditure function E(P1,P2,U) = [4/3 P1P2U]1/2 - P1/3 1. Show that the expenditure...

    Consider the following expenditure function E(P1,P2,U) = [4/3 P1P2U]1/2 - P1/3 1. Show that the expenditure function is appropriately homogeneous. 2. Derive the compensated (Hickisian) demand function for commodity 1 and commodity 2. 3. Derive the compensated own price elasticity for both commodities 4. Derive the compensated cross price elasticity for both goods 5. Derive the indirect utility function. 6. Show that the indirect utility function is appropriately homogeneous 7. Derive the ordinary demand function for good 1 and good...

  • You choose a random permutation (p1, p2, p3, p4, p5, p6, p7) of 1, 2, 3,...

    You choose a random permutation (p1, p2, p3, p4, p5, p6, p7) of 1, 2, 3, 4, 5, 6, 7, with each of the 7! permutations equally likely. What is the probability that (1 + p1)(2 + p2)(3 + p3)(4 + p4)(5 + p5)(6 + p6)(7 + p7) is even? Give an exact answer as a simplified fraction and justify your answer.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT