Gate2019 cs Q33

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

P1P2P3
:::
:::
D = D + 20D = 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 _____________.

Note – Numerical Type question

  • Option : A
  • Explanation :
    Minimum value (X) of D will possible when,

    P2 reads D=100, preempted.
    P1 executes D=D+20, D=120.
    P3 executes D=D+10, D=130.
    Now, P2 has D=100, executes, D = D-50 = 100-50 = 50. P2 writes D=50 final value.
    So, minimum value (X) of D is 50.
    Maximum value (Y) of D will possible when,

    P1 reads D=100, preempted.
    P2 reads D=100, executes, D = D-50 = 100-50 = 50.
    Now, P1 executes, D = D+20 = 100+20 = 120.
    And now, P3 reads D=120, executes D=D+10, D=130. P3 writes D=130 final value.
    So, maximum value (Y) of D is 130.

    Therefore,
    = Y - X
    = 130 - 50
    = 80
    So, option (A) is correct.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *