Self Studies

Operating System Test 3

Result Self Studies

Operating System Test 3
  • Score

    -

    out of -
  • Rank

    -

    out of -
TIME Taken - -
Self Studies

SHARING IS CARING

If our Website helped you a little, then kindly spread our voice using Social Networks. Spread our word to your readers, friends, teachers, students & all those close ones who deserve to know what you know now.

Self Studies Self Studies
Weekly Quiz Competition
  • Question 1
    1 / -0
    Consider a counting semaphore which was initialized to (y + 7) for a system. Seven wait and (y+ 3) signal operations were completed on this semaphore. If the final value of the semaphore is (y + 2) then what is the value of y?
    Solution

    Concepts:

    V(S): Signal will increment the semaphore variable, that is, S++.

    P(S): Wait will decrement the semaphore variable., that is, S--.

    Data:

    Initial counting semaphore = I = y + 7

    Wait operation = 7 P

    Signal operation = (y+3) V

    Final counting semaphore = F = y+2

    Formula:

    F = I + 7 × P + (y+3) × V

    Calculation:

    y + 2 = y + 7 + 7 × (-1) + (y+3)(+1)

    y + 2 = 2y + 3

    ∴ y = -1

    the resulting value of y is -1
  • Question 2
    1 / -0
    Which of the following is false about Peterson’s synchronization mechanism?
    Solution

    Peterson’s synchronization mechanism:

    • It is a busy waiting solution.
    • Mutual exclusion and progress are guaranteed.
    • It doesn’t use semaphore variable, but it uses to integer variables (turn and interest) to achieve synchronization.
  • Question 3
    1 / -0

    Let P, Q, R be the three concurrent processes as shown below, which access a shared variable A that has been initialized to 150

    P

    Q

    R

    :

    :

    A = A + 30

    :

    :

    :

    :

    A = A - 40

    :

    :

    :

    :

    A = A + 15

    :

    :

     

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

    Maximum value (N):

    • Process P reads the initial value 150 during execution P will update the value of A to (150 + 30 = 180) and writes it to memory.
    • Q and R read the value 180 from the memory.
    • Q will get executed before P and write the value (180 - 40 = 140) to memory. Since R is holding A = 180 after its execution A will be equal to (180 + 15 = 195) ∴ N = 195

    Minimum value (M):

    • P, Q and R read the value 150 from the memory
    • P will execute first, after its execution it will update (A = 150 + 30 = 180)
    • After P, R will execute and it will update the value to (A = 180 + 15 = 195)
    • Finally, Q will be execute and A will be equal to 150 - 40 = 110 ∴ M = 110
    • N - M = 195 - 110 = 85
  • Question 4
    1 / -0
    Suppose P, Q and R are co-operating processes satisfying Mutual Exclusion condition. Then if the process Q is executing in its critical section then
    Solution

    Concepts:

    A mutual exclusion (mutex) is a program object that prevents simultaneous access to a shared resource.

    A critical section is a code segment that accesses shared variables and has to be executed as an atomic action. The critical section problem refers to the problem of how to ensure that at most one process is executing its critical section at a given time.

    PROCESS:

    ENTRY SECTION

    Process Q

    CRITICAL SECTION

    EXIT SECTION

    REMAINDER SECTION

     

    Since process ‘Q’ is in critical section then other processes P and R cannot be in the critical section. Therefore neither ‘P’ nor ‘R’ executes in their critical section.
  • Question 5
    1 / -0

    Two concurrent processes P and Q execute the following code.

    Process P:

    While (True){

    W:_____

    Print(‘0’); print(‘0’);

    X:____

    }

    Process q;

    While (True){

    Y;

    print(‘1’); print(‘1’);

    Z:_____

    }

    Given S and T are binary semaphore variables, and P() and V() as standard “wait” and “signal” functions respectively. What should be the semaphore operations W, X, Y, and Z for the output string: 11001100…? 
    Solution

    For the output string: 11001100…….

    We have to take,

    For process P:

    W = P(T)

    X = V (S)

    For process q:

    Y = P(S)

    Z = V (T), where, S = 1 and T = 0

    So, in this when we try to execute process P, it will go to P(T) as T = 0, it cannot enter into critical section.

    So, we try to execute process Q.

    It will go to P(S), As S = 1, so process q will enter into critical section and make S = 0 and print 11, then after its exit from critical section only, we can execute process P and print 00.

    So, both process P and Q depends on each other to enter the critical section. In this way, it prints the sequence 11001100……
  • Question 6
    1 / -0

    The following two functions F1 and F2 that share a variable X, Y with an initial value 10 execute concurrently.

    F1()

    {

    Y = X – 5;

    S = 5 × Y;

    }

    F2()

    {

    Y = 5 × X;

    S = Y – 5;

    }

    Find the sum of the distinct values that S can possibly take after the execution?
    Solution

    X = 10
    F1:

    Y = 10 – 5 = 5

    S = 5 × (5) = 25

    F2:

    Y = 5 × 10= 50

    S = Y – 5 = 50 – 5 = 45

    Also

    S = Y – 5 = 5 – 5 = 0

    S = 5 × 50 = 250

    ∴ sum = 25 + 45 + 0 + 250 = 320

    Confusion Points:

    Since functions run concurrently, any execution order is possible, that is, after F1 line number 1 F2 line number can be executed and so on…
  • Question 7
    1 / -0

    To overcome difficulties in Readers-Writers problem, which of the following statement/s is/are true?

    1) Writers are given exclusive access to shared objects

    2) Readers are given exclusive access to shared objects

    3) Both readers and writers are given exclusive access to shared objects.

    Choose the correct answer from the code given below:
    Solution

    In Readers-Writers problem, more than one Reader is allowed to read simultaneously but if a Writer is writing then no other writer or any reader can have simultaneous access to that shared object. So, Writers are given exclusive access to shared objects.

    Hence option 1 is correct

  • Question 8
    1 / -0

    Let flag be declared as Boolean flag[2] set to false and i = 1 - j

    while(1)

    {

    flag[i] = true;

    while(flag[j]);

    <critical section>

    flag[i] = false;

    <remainder section>

    }

    Lets two processes execute concurrently, then in the above case.

    Solution

    If process0 makes flag[0] = true and process1 makes flag[1] = true without executing the while statement, it will lead to deadlock.

    Now even if one process wants to enter in critical section other will stop since it had already made the flag variable true.

    Therefore, the progress is not guaranteed

    If process0 is in the critical section then process1 cannot enter into it since the variable of process0 is true and while statement of process1 will execute infinitely and vice versa.

    If deadlock won't happen then critical section, will access by processes alternately and hence bounded waiting is guaranteed. 

    Therefore option 2 is correct

  • Question 9
    1 / -0
    Consider a non-negative counting semaphore S. The operation P(S) performs the operation --S and operation V(S) perform the operation ++V. During program execution, 17P and 11V operation is performed in the some order. What is the smallest initial value of S for which at most 4 processes are in the blocked state?
    Solution

    Concepts:

    V(S): Signal will increment the semaphore variable, that is, S++. 

    P(S): Signal will decrement the semaphore variable., that is, S--. 

    Data:

    Initial counting semaphore = x

    Signal operation = 11 V

    Wait operation = 17 P

    Since at most 3 process in blocked state

    Final counting semaphore (F) = -4

    Formula:

    F ≤ x + 17P + 11V

    Calculation:

    -4 ≤ x + 17(-1) + 11(+1)

    x ≥ 2

    ∴ smallest value of initial semaphore count is 2
  • Question 10
    1 / -0

    Let each process Pi, i = 1 to 7 executes the following code.

    repeat

    P(mutex);

    CS

    V(mutex);

    forever

    The process P8 executes the following code:

    repeat

    V(mutex);

    CS

    V(mutex);

    forever

    What is the maximum number of processes that can be present in the critical section at any point of time? Given that the initial value of binary semaphore variable “mutex” is 1.
    Solution

    Here mutex = 1

    first, take Process 1, that is, P1

    P(mutex);

    CS

    V(mutex);

    This code will run. mutex = 0 and P1 will move into the critical section.

    After this, try to enter the P8 in the critical section, it will run the code :

    V(mutex);

    CS

    V(mutex);

    In this case, it will changes mutex into 1, and P8 will enter into the critical section. After this, exit the P8 from the critical section, it will change mutex to 2. Then again enter P8. In this way, it increases the mutex value always.

    In this way, if Mutex becomes 8 then all the 8 processes can simultaneously enter the critical section.

    SO, the maximum number of processes that can be present in the critical section at any point in time = 8.
Self Studies
User
Question Analysis
  • Correct -

  • Wrong -

  • Skipped -

My Perfomance
  • Score

    -

    out of -
  • Rank

    -

    out of -
Re-Attempt Weekly Quiz Competition
Selfstudy
Selfstudy
Self Studies Get latest Exam Updates
& Study Material Alerts!
No, Thanks
Self Studies
Click on Allow to receive notifications
Allow Notification
Self Studies
Self Studies Self Studies
To enable notifications follow this 2 steps:
  • First Click on Secure Icon Self Studies
  • Second click on the toggle icon
Allow Notification
Get latest Exam Updates & FREE Study Material Alerts!
Self Studies ×
Open Now