Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
472 views
in Computer by (88.5k points)
closed by

Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100.

P1

P2

P3

:

:

D = D + 20

:

:

:

:

D = D - 50

:

:

:

:

D = D + 10

:

:

 

The processes are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, then the value of Y - X is __________.

1 Answer

0 votes
by (85.4k points)
selected by
 
Best answer

Maximum value (Y):

  • Process P1 reads the initial value 100 during execution P1 will update the value of D to (100 + 20 = 120) and writes it to memory.
  • P2 and P3 read the value 120 from the memory.
  • P2 will get executed before P1 and write the value (120 - 50 = 70) to memory. Since P3 is holding D = 120 after its execution D will be equal to (120 + 10 = 130) ∴ Y = 130

Minimum value (X):

  • P1, P2 and P3 read the value 100 from the memory
  • P1 will execute first, after its execution it will update (D = 100 + 20 = 120)
  • After P1, P3 will execute and it will update the value to (D = 100 + 10 = 110)
  • Finally, P2 will be execute and D will be equal to 100 - 50 = 50 ∴ X = 50
  • Y - X = 130 - 50 = 80

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...