Study Korner

Quiz – Process Management

Time limit: 0

Quiz-summary

0 of 99 questions completed

Questions:

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
  99. 99

Information

Operating Systems – Process Management

You have already completed the quiz before. Hence you can not start it again.

Quiz is loading...

You must sign in or sign up to start the quiz.

You have to finish following quiz, to start this quiz:

Results

0 of 99 questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 points, (0)

Categories

  1. Not categorized 0%
  2. GateCS2013 0%
  3. ISRO CS 2007 0%
  4. ISRO CS 2008 0%
  5. ISRO CS 2008 0%
  6. ISRO CS 2008 0%
  7. ISRO CS 2018 0%
  8. UGC NET 2015 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
  99. 99
  1. Answered
  2. Review
  1. Question 1 of 99
    Question 1

    Consider the following code fragment:

      if (fork() == 0)
      { 
       a = a + 5; 
       printf("%d,%dn", a, &a); 
      }
     else 
      { 
       a = a –5; 
       printf("%d, %dn", a, &a); 
      } 
    

    Let u, v be the values printed by the parent process, and x, y be the values printed by the child process. Which one of the following is TRUE?

    Correct

    Explanation:
    fork() returns 0 in child process and process ID of child process in parent process. In Child (x), a = a + 5 In Parent (u), a = a – 5; Therefore x = u + 10. The physical addresses of ‘a’ in parent and child must be different. But our program accesses virtual addresses (assuming we are running on an OS that uses virtual memory). The child process gets an exact copy of parent process and virtual address of ‘a’ doesn’t change in child process. Therefore, we get same addresses in both parent and child.

    Incorrect

    Correct option is ” u + 10 = x and v = y”
    Explanation:-
    fork() returns 0 in child process and process ID of child process in parent process. In Child (x), a = a + 5 In Parent (u), a = a – 5; Therefore x = u + 10. The physical addresses of ‘a’ in parent and child must be different. But our program accesses virtual addresses (assuming we are running on an OS that uses virtual memory). The child process gets an exact copy of parent process and virtual address of ‘a’ doesn’t change in child process. Therefore, we get same addresses in both parent and child.

  2. Question 2 of 99
    Question 2

    The atomic fetch-and-set x, y instruction unconditionally sets the memory location x to 1 and fetches the old value of x in y without allowing any intervening access to the memory location x. consider the following implementation of P and V functions on a binary semaphore .

    void P (binary_semaphore *s) {
      unsigned y;
      unsigned *x = &(s->value);
      do {
         fetch-and-set x, y;
      } while (y);
    }
    
    void V (binary_semaphore *s) {
      S->value = 0;
    }
    

    Which one of the following is true?

    Correct

    Let us talk about the operation P(). It stores the value of s in x, then it fetches the old value of x, stores it in y and sets x as 1. The while loop of a process will continue forever if some other process doesn’t execute V() and sets the value of s as 0. If context switching is disabled in P, the while loop will run forever as no other process will be able to execute V().

    Incorrect

    Option 1. is correct.
    Let us talk about the operation P(). It stores the value of s in x, then it fetches the old value of x, stores it in y and sets x as 1. The while loop of a process will continue forever if some other process doesn’t execute V() and sets the value of s as 0. If context switching is disabled in P, the while loop will run forever as no other process will be able to execute V().

  3. Question 3 of 99
    Question 3

    Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P operation on semaphores c, d, and a before entering the respective code segments. After completing the execution of its code segment, each process invokes the V operation (i.e., signal) on its three semaphores. All semaphores are binary semaphores initialized to one. Which one of the following represents a deadlockfree order of invoking the P operations by the processes?
    [GATE CS 2013]

    Correct

    Option 1 can cause deadlock. Imagine a situation process X has acquired a, process Y has acquired b and process Z has acquired c and d. There is circular wait now.
    Option 3 can also cause deadlock. Imagine a situation process X has acquired b, process Y has acquired c and process Z has acquired a. There is circular wait now.
    Option 4 can also cause deadlock. Imagine a situation process X has acquired a and b, process Y has acquired c. X and Y circularly waiting for each other.

    Incorrect

    Correct option is 2
    Option 1 can cause deadlock. Imagine a situation process X has acquired a, process Y has acquired b and process Z has acquired c and d. There is circular wait now.
    Option 3 can also cause deadlock. Imagine a situation process X has acquired b, process Y has acquired c and process Z has acquired a. There is circular wait now.
    Option 4 can also cause deadlock. Imagine a situation process X has acquired a and b, process Y has acquired c. X and Y circularly waiting for each other.

  4. Question 4 of 99
    Question 4

    A shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process before reading x invokes the P operation (i.e., wait) on a counting semaphore S and invokes the V operation (i.e., signal) on the semaphore S after storing x to memory. Semaphore S is initialized to two. What is the maximum possible value of x after all processes complete execution?
    [GATE CS 2013]

    Correct

    Processes can run in many ways, below is one of the cases in which x attains max value

    
    s = 2
    Process W executes S=1, x=1 but it doesn't update the x variable.
    
    Then process Y executes S=0, it decrements x, now x= -2 and 
    signal semaphore S=1
    
    Now process Z executes s=0, x=-4, signal semaphore S=1
    
    Now process W updates x=1, S=2
    
    Then process X executes X=2 
    
    Incorrect

    Correct option is 1
    Processes can run in many ways, below is one of the cases in which x attains max value

    
    s = 2
    Process W executes S=1, x=1 but it doesn't update the x variable.
    
    Then process Y executes S=0, it decrements x, now x= -2 and 
    signal semaphore S=1
    
    Now process Z executes s=0, x=-4, signal semaphore S=1
    
    Now process W updates x=1, S=2
    
    Then process X executes X=2 
    
  5. Question 5 of 99
    Question 5

    A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.

           Process X:                         Process Y:
    private i;                         private i;
    for (i=0; i < n; i++) {            for (i=0; i < n; i++) {
       a[i] = f(i);                       EntryY(R, S);
       ExitX(R, S);                       b[i]=g(a[i]);
    }                                 }
    

    Which one of the following represents the CORRECT implementations of ExitX and EntryY?

    Correct

    The purpose here is neither the deadlock should occur nor the binary semaphores be assigned value greater than one.
    1. leads to deadlock
    2. can increase value of semaphores b/w 1 to n
    4. may increase the value of semaphore R and S to 2 in some cases

    Incorrect

    Correct option is 3
    The purpose here is neither the deadlock should occur nor the binary semaphores be assigned value greater than one.
    1. leads to deadlock
    2. can increase value of semaphores b/w 1 to n
    4. may increase the value of semaphore R and S to 2 in some cases

  6. Question 6 of 99
    Question 6

    A process executes the code

    fork();
    fork();
    fork(); 
    

    The total number of child processes created is

    Correct

    Let us put some label names for the three lines

      fork ();    // Line 1
      fork ();   // Line 2
      fork ();   // Line 3
    
              Line1         // There will be 1 child process 
             /     \        // created by line 1
       Line2         Line2  // There will be 2 child 
       /   \          /  \  // processes created by line 2
    Line3  Line3  Line3  Line3  // There will be 4 child 
                                // processes created by line 3
    

    We can also use direct formula to get the number of child processes. With n fork statements, there are always 2^n – 1 child processes.

    Incorrect

    Correct option is 3.
    Let us put some label names for the three lines

      fork ();    // Line 1
      fork ();   // Line 2
      fork ();   // Line 3
    
              Line1         // There will be 1 child process 
             /     \        // created by line 1
       Line2         Line2  // There will be 2 child 
       /   \          /  \  // processes created by line 2
    Line3  Line3  Line3  Line3  // There will be 4 child 
                                // processes created by line 3
    

    We can also use direct formula to get the number of child processes. With n fork statements, there are always 2^n – 1 child processes.

  7. Question 7 of 99
    Question 7

    Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments it by the value i, and returns the old value of X. It is used in the pseudocode shown below to implement a busy-wait lock. L is an unsigned integer shared variable initialized to 0. The value of 0 corresponds to lock being available, while any non-zero value corresponds to the lock being not available.

      AcquireLock(L){
             while (Fetch_And_Add(L,1))
                   L = 1;
       }
      ReleaseLock(L){
             L = 0;
       }
    

    This implementation
    [Gate CS 2012]

    Correct

    Incorrect

  8. Question 8 of 99
    Question 8

    The time taken to switch between user and kernel modes of execution be t1 while the time taken to switch between two processes be t2. Which of the following is TRUE?
    [Gate CS 2011]

    Correct

    Process switches or Context switches can occur in only kernel mode . So for process switches first we have to move from user to kernel mode . Then we have to save the PCB of the process from which we are taking off CPU and then we have to load PCB of the required process . At switching from kernel to user mode is done. But switching from user to kernel mode is a very fast operation(OS has to just change single bit at hardware level)

    Incorrect

    Correct option is 1.
    Process switches or Context switches can occur in only kernel mode . So for process switches first we have to move from user to kernel mode . Then we have to save the PCB of the process from which we are taking off CPU and then we have to load PCB of the required process . At switching from kernel to user mode is done. But switching from user to kernel mode is a very fast operation(OS has to just change single bit at hardware level)

  9. Question 9 of 99
    Question 9

    A thread is usually defined as a “light weight process” because an operating system (OS) maintains smaller data structures for a thread than for a process. In relation to this, which of the following is TRUE?

    Correct

    Threads share address space of Process. Virtually memory is concerned with processes not with Threads. A thread consists “a program counter, a stack, and a set of registers, (and a thread ID)”.
    PCB
    As explained in above figure we can see that, for a single thread of control – there is one program counter, and one sequence of instructions that can be carried out at any given time and for multi-threaded applications-there are multiple threads within a single process, each having their own program counter, stack and set of registers, but sharing common code, data, and certain structures such as open files.
    Option (1): is not correct as it says OS maintains only CPU register state.
    Option (2): correct
    Option (3): it says OS does not maintain a separate stack for each thread. But as per the above diagram, for each thread, separate stack is maintained. So this option is also incorrect.
    Option (4): the OS maintains only scheduling and accounting information. But other information like cpu registers stack, program counters, data files, code files are also maintained, so it is also not correct

    Incorrect

    Correct option is 2.
    Threads share address space of Process. Virtually memory is concerned with processes not with Threads. A thread consists “a program counter, a stack, and a set of registers, (and a thread ID)”.

    As explained in above figure we can see that, for a single thread of control – there is one program counter, and one sequence of instructions that can be carried out at any given time and for multi-threaded applications-there are multiple threads within a single process, each having their own program counter, stack and set of registers, but sharing common code, data, and certain structures such as open files.
    Option (1): is not correct as it says OS maintains only CPU register state.
    Option (2): correct
    Option (3): it says OS does not maintain a separate stack for each thread. But as per the above diagram, for each thread, separate stack is maintained. So this option is also incorrect.
    Option (4): the OS maintains only scheduling and accounting information. But other information like cpu registers stack, program counters, data files, code files are also maintained, so it is also not correct

  10. Question 10 of 99
    Question 10

    Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned.

    Method Used by P1
    while (S1 == S2) ;
    Critical Section
    S1 = S2;
    
    Method Used by P2
    while (S1 != S2) ;
    Critical Section
    S2 = not (S1);
    

    Which one of the following statements describes the properties achieved?
    [Gate CS 2010]

    Correct

    Progress Requirement is not satisfied. Suppose when s1=1 and s2=0 and process p1 is not interested to enter into critical section but p2 want to enter critical section. P2 is not able to enter critical section in this as only when p1 finishes execution, then only p2 can enter (then only s1 = s2 condition be satisfied). Progress will not be satisfied when any process which is not interested to enter into the critical section will not allow other interested process to enter into the critical section.

    Incorrect

    Correct option is 1.
    Progress Requirement is not satisfied. Suppose when s1=1 and s2=0 and process p1 is not interested to enter into critical section but p2 want to enter critical section. P2 is not able to enter critical section in this as only when p1 finishes execution, then only p2 can enter (then only s1 = s2 condition be satisfied). Progress will not be satisfied when any process which is not interested to enter into the critical section will not allow other interested process to enter into the critical section

  11. Question 11 of 99
    Question 11

    The following program consists of 3 concurrent processes and 3 binary semaphores.The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.

    GateCS2010Q42


    How many times will process P0 print ‘0’?
    Correct

    Initially only P0 can go inside the while loop as S0 = 1, S1 = 0, S2 = 0. P0 first prints ‘0’ then, after releasing S1 and S2, either P1 or P2 will execute and release S0. So 0 is printed again.

    Incorrect

    The correct option is 1.
    Initially only P0 can go inside the while loop as S0 = 1, S1 = 0, S2 = 0. P0 first prints ‘0’ then, after releasing S1 and S2, either P1 or P2 will execute and release S0. So 0 is printed again.

  12. Question 12 of 99
    Question 12

    The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction as follows:

    void enter_CS(X)
    {
        while test-and-set(X) ;
    }
    void leave_CS(X)
    {
       X = 0;
    }
    

    In the above solution, X is a memory location associated with the CS and is initialized to 0. Now consider the following statements:
    I. The above solution to CS problem is deadlock-free
    II. The solution is starvation free.
    III. The processes enter CS in FIFO order.
    IV More than one process can enter CS at the same time.
    Which of the above statements is TRUE?
    [Gate CS 2009]

    Correct

    The above solution is a simple test-and-set solution that makes sure that deadlock doesn’t occur, but it doesn’t use any queue to avoid starvation or to have FIFO order.

    Incorrect

    Correct option is 1.

  13. Question 13 of 99
    Question 13

    A process executes the following code

    for (i = 0; i < n; i++) 
         fork();
    

    The total number of child processes created is
    [Gate CS 2008, ISRO 2017]

    Correct

    If we sum all levels of above tree for i = 0 to n-1, we get 2n – 1. So there will be 2n – 1 child processes. On the other hand, the total number of process created are (number of child processes)+1.

    Note:The maximum number of process is 2n and may vary due to fork failures.Also see this post for more details.

    Incorrect

    Correct option is 2.
    If we sum all levels of above tree for i = 0 to n-1, we get 2n – 1. So there will be 2n – 1 child processes. On the other hand, the total number of process created are (number of child processes)+1.

    Note:The maximum number of process is 2n and may vary due to fork failures.Also see this post for more details.

  14. Question 14 of 99
    Question 14

    Consider the following statements about user level threads and kernel level threads. Which one of the following statement is FALSE?

    Correct

    Kernel level threads are managed by the OS, therefore, thread operations are implemented in the kernel code. Kernel level threads can also utilize multiprocessor systems by splitting threads on different processors. If one thread blocks it does not cause the entire process to block. Kernel level threads have disadvantages as well. They are slower than user level threads due to the management overhead. Kernel level context switch involves more steps than just saving some registers. Kernel Level threads are not portable because the implementation is operating system dependent.

    Incorrect

    Correct option is 4.
    Kernel level threads are managed by the OS, therefore, thread operations are implemented in the kernel code. Kernel level threads can also utilize multiprocessor systems by splitting threads on different processors. If one thread blocks it does not cause the entire process to block. Kernel level threads have disadvantages as well. They are slower than user level threads due to the management overhead. Kernel level context switch involves more steps than just saving some registers. Kernel Level threads are not portable because the implementation is operating system dependent.

  15. Question 15 of 99
    Question 15

    Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false.

      /* P1 */
    while (true) {
      wants1 = true;
      while (wants2 == true);
      /* Critical
        Section */
      wants1=false;
    }
    /* Remainder section */       
    
    
    /* P2 */
    while (true) {
      wants2 = true;
      while (wants1==true);
      /* Critical
        Section */
      wants2 = false;
    }
    /* Remainder section */
    

    Which one of the following statements is TRUE about the above construct?
    [Gate CS 2007]

    Correct

    wants1 and wants2 are shared variables, initialized to false. When both wants1 and wants2 become true, both process P1 and P2 enter in while loop and waiting for each other to finish. This while loop run indefinitely which leads to deadlock.
    Now, Assume P1 is in critical section (i.e. wants1=true, wants2 can be anything, true or false). So this ensures that P2 won’t enter in critical section and vice versa hence mutual exclusion is satisfied. Bounded waiting condition is also satisfied, as there is a bound on the number of process which gets access to critical section after a process request access to critical section.

    Incorrect

    Correct option is 4.
    wants1 and wants2 are shared variables, initialized to false. When both wants1 and wants2 become true, both process P1 and P2 enter in while loop and waiting for each other to finish. This while loop run indefinitely which leads to deadlock.
    Now, Assume P1 is in critical section (i.e. wants1=true, wants2 can be anything, true or false). So this ensures that P2 won’t enter in critical section and vice versa hence mutual exclusion is satisfied. Bounded waiting condition is also satisfied, as there is a bound on the number of process which gets access to critical section after a process request access to critical section.

  16. Question 16 of 99
    Question 16

    Which one of the following is FALSE?
    [Gate CS 2014]

    Correct

    User level thread Kernel level thread
    User thread are implemented by user processes. kernel threads are implemented by OS.
    OS doesn’t recognized user level threads. Kernel threads are recognized by OS.
    Implementation of User threads is easy. Implementation of Kernel thread is complicated.
    Context switch time is less. Context switch time is more.
    Context switch requires no hardware support. Hardware support is needed.
    If one user level thread perform blocking operation then entire process will be blocked. If one kernel thread perform blocking operation then another thread can continue execution.
    Example : Java thread, POSIX threads. Example : Window Solaris.
    Incorrect

    Correct option is 4.

    User level thread Kernel level thread
    User thread are implemented by user processes. kernel threads are implemented by OS.
    OS doesn’t recognized user level threads. Kernel threads are recognized by OS.
    Implementation of User threads is easy. Implementation of Kernel thread is complicated.
    Context switch time is less. Context switch time is more.
    Context switch requires no hardware support. Hardware support is needed.
    If one user level thread perform blocking operation then entire process will be blocked. If one kernel thread perform blocking operation then another thread can continue execution.
    Example : Java thread, POSIX threads. Example : Window Solaris.
  17. Question 17 of 99
    Question 17

    Consider two processors P1 and P2 executing the same instruction set. Assume that under identical conditions, for the same input, a program running on P2 takes 25% less time but incurs 20% more CPI (clock cycles per instruction) as compared to the program running on P1. If the clock frequency of P1 is 1GHz, then the clock frequency of P2 (in GHz) is _________.
    [Gate CS 2014]

    Correct

    For P1 clock period = 1ns
    Let clock period for P2 be t.

    Now consider following equation based on specification
    7.5 ns = 12*t ns
    We get t and inverse of t will be 1.6GHz

    Incorrect

    Correct option is 1.
    For P1 clock period = 1ns
    Let clock period for P2 be t.

    Now consider following equation based on specification
    7.5 ns = 12*t ns
    We get t and inverse of t will be 1.6GHz

  18. Question 18 of 99
    Question 18

    Consider the procedure below for the Producer-Consumer problem which uses semaphores:

    Which one of the following is TRUE?
    [Gate CS 2014]

    Correct

    Semaphore s=1 and semaphore n=0.
    We assume that initially control goes to the consumer when buffer is empty.
    semWait(s) => s=s-1 => s=0.
    semWait(n) tries to decrements the value of semaphore ‘n’. Since, the value of semaphore ‘n’ becomes less than 0 , the control stucks in function semWait() and a deadlock arises.
    Thus, deadlock occurs if the consumer succeeds in acquiring semaphore s when the buffer is empty.

    Incorrect

    Correct option is 3.
    Semaphore s=1 and semaphore n=0.
    We assume that initially control goes to the consumer when buffer is empty.
    semWait(s) => s=s-1 => s=0.
    semWait(n) tries to decrements the value of semaphore ‘n’. Since, the value of semaphore ‘n’ becomes less than 0 , the control stucks in function semWait() and a deadlock arises.
    Thus, deadlock occurs if the consumer succeeds in acquiring semaphore s when the buffer is empty.

  19. Question 19 of 99
    Question 19

    The atomic fetch-and-set x, y instruction unconditionally sets the memory location x to 1 and fetches the old value of x n y without allowing any intervening access to the memory location x. consider the following implementation of P and V functions on a binary semaphore S.

    void P (binary_semaphore *s)
    {
        unsigned y;
        unsigned *x = &(s->value);
        do
        {
            fetch-and-set x, y;
        }
        while (y);
    }
    void V (binary_semaphore *s)
    {
        S->value = 0;
    } 
    

    Which one of the following is true?
    [Gate CS 2006]

    Correct
    P(S) or wait(S): 
     If S > 0 then
       Set S to S-1
     Else
       Block the calling process (i.e. Wait on S)
    

    P(s) stores the value of s in x, then it fetches the old value of x, stores it in y and sets x as 1. The while loop of a process will continue forever if some other process doesn’t execute V() and sets the value of s as 0. If context switching is disabled in P, the while loop will run forever as no other process will be able to execute V().

    Incorrect

    Correct option is `1.

    P(S) or wait(S): 
     If S > 0 then
       Set S to S-1
     Else
       Block the calling process (i.e. Wait on S)
    

    P(s) stores the value of s in x, then it fetches the old value of x, stores it in y and sets x as 1. The while loop of a process will continue forever if some other process doesn’t execute V() and sets the value of s as 0. If context switching is disabled in P, the while loop will run forever as no other process will be able to execute V().

  20. Question 20 of 99
    Question 20

    Which of the following is false?
    [ISRO 2017]

    Correct

    User level threads exist in user space and kernel is not aware of user level threads, so kernel cannot schedule user level threads.
    While context switching among user level threads, kernel is not aware of user level threads so for kernel no context switching occur for user level threads and no need to do anything, while in case of kernel level threads context switching, kernel need to swap out and swap in threads by saving TCBs (Thread control blocks) and loading of TCB means more time required.
    Again, as kernel is not aware of user level threads so when a user level thread is blocked kernel does not know whether other threads available for execution and could not able to schedule another thread available in user space and which leads to blockage of a process.
    Multiple independent kernel level threads can be scheduled on multiple cores at a time.

    Incorrect

    Correct option is 4.
    User level threads exist in user space and kernel is not aware of user level threads, so kernel cannot schedule user level threads.
    While context switching among user level threads, kernel is not aware of user level threads so for kernel no context switching occur for user level threads and no need to do anything, while in case of kernel level threads context switching, kernel need to swap out and swap in threads by saving TCBs (Thread control blocks) and loading of TCB means more time required.
    Again, as kernel is not aware of user level threads so when a user level thread is blocked kernel does not know whether other threads available for execution and could not able to schedule another thread available in user space and which leads to blockage of a process.
    Multiple independent kernel level threads can be scheduled on multiple cores at a time.

  21. Question 21 of 99
    Question 21

    Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three and S be a binary semaphore with the usual P and V functions. Consider the following C implementation of a barrier with line numbers shown on left.

    void barrier (void) {
       P(S);
       process_arrived++;
       V(S);
       while (process_arrived !=3);
       P(S);
       process_left++;
       if (process_left==3) {
          process_arrived = 0;
          process_left = 0;
      }
      V(S);
    }
    

    The variables process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally. Which one of the following rectifies the problem in the implementation?
    [Gate CS 2006]

    Correct

    To prevent variable process_arrived becoming greater than 3, step ‘2’ should not be executed when the process enters the barrier second time till other two processes have not completed their 7th step.
    To avoid the deadlock, (variable process_arrived becomes 0, the variable process_left also should be 0)
    Thus, at the beginning of the function barrier the first process to enter the barrier waits until process_arrived becomes 0 before proceeding to execute P(S).

    Incorrect

    Correct option is 2.
    To prevent variable process_arrived becoming greater than 3, step ‘2’ should not be executed when the process enters the barrier second time till other two processes have not completed their 7th step.
    To avoid the deadlock, (variable process_arrived becomes 0, the variable process_left also should be 0)
    Thus, at the beginning of the function barrier the first process to enter the barrier waits until process_arrived becomes 0 before proceeding to execute P(S).

  22. Question 22 of 99
    Question 22

    Consider two processes P1 and P2 accessing the shared variables X and Y protected by two binary semaphores SX and SY respectively, both initialized to 1. P and V denote the usual semaphone operators, where P decrements the semaphore value, and V increments the semaphore value. The pseudo-code of P1 and P2 is as follows :
    P1 :

     While true do {
       L1 : ................
       L2 : ................
       X = X + 1;
       Y = Y - 1;
       V(SX);
       V(SY);             
     }
    

    P2 :

     While true do {
       L3 : ................   
       L4 : ................
       Y = Y + 1;
       X = Y - 1;
       V(SY);
       V(SX);            
    }
    

    In order to avoid deadlock, the correct operators at L1, L2, L3 and L4 are respectively:
    [Gate CS 2004]

    Correct

    Option 1: P1 wants lock on Sy that is held by process P2 and in line L3 P(Sx) P2 wants lock on Sx which is held by p1.
    So, circular wait condition exist which leads to deadlock.

    Option 2 : In line L1: p(Sx), P1 wants lock on Sx which is held by P2 and in line L3: p(Sy), P2 wants lock on Sx which is held by P1. So circular wait condition exist => deadlock.

    Option 3: L1: p(Sx) P1 wants lock on Sx and in line L3: p(Sy) P2 wants lock on Sx . But Sx and Sy can’t be released by p1 and p2.

    Incorrect

    Correct option is 4.
    Option 1: P1 wants lock on Sy that is held by process P2 and in line L3 P(Sx) P2 wants lock on Sx which is held by p1.
    So, circular wait condition exist which leads to deadlock.

    Option 2 : In line L1: p(Sx), P1 wants lock on Sx which is held by P2 and in line L3: p(Sy), P2 wants lock on Sx which is held by P1. So circular wait condition exist => deadlock.

    Option 3: L1: p(Sx) P1 wants lock on Sx and in line L3: p(Sy) P2 wants lock on Sx . But Sx and Sy can’t be released by p1 and p2.

  23. Question 23 of 99
    Question 23

    Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T. The code for the processes P and Q is shown below.
    Process P:

    while (1) {
    W:
       print '0';
       print '0';
    X:
    }
    

    Process Q:

    while (1) {
    Y:
       print '1';
       print '1';
    Z:
    }
    

    Synchronization statements can be inserted only at points W, X, Y and Z. Which of the following will always lead to an output staring with ‘001100110011’ ?
    [Gate CS 2003]

    Correct

    Both processes should execute in interleaving manner starting from process P.
    Initially Q should be blocked and P should execute. While leaving the P should unblock Q.
    Similarly P should be blocked until Q unblocks P while exiting.

    Incorrect

    Correct option is 2.
    Both processes should execute in interleaving manner starting from process P.
    Initially Q should be blocked and P should execute. While leaving the P should unblock Q.
    Similarly P should be blocked until Q unblocks P while exiting.

  24. Question 24 of 99
    Question 24

    Which of the following does not interrupt a running process?
    [Gate CS 2001]

    Correct

    Scheduler process doesn’t interrupt any process, it’s Job is to select the processes for following three purposes:
    1. Long-term scheduler(or job scheduler) – selects which processes should be brought into the ready queue
    2. Short-term scheduler(or CPU scheduler) – selects which process should be executed next and allocates CPU.
    3. Mid-term Scheduler (Swapper) – present in all systems with virtual memory, temporarily removes processes from main memory and places them on secondary memory (such as a disk drive) or vice versa.

    Incorrect

    Correct option is 3.
    Scheduler process doesn’t interrupt any process, it’s Job is to select the processes for following three purposes. Long-term scheduler(or job scheduler) –selects which processes should be brought into the ready queue Short-term scheduler(or CPU scheduler) –selects which process should be executed next and allocates CPU. Mid-term Scheduler (Swapper)- present in all systems with virtual memory, temporarily removes processes from main memory and places them on secondary memory (such as a disk drive) or vice versa. The mid-term scheduler may decide to swap out a process which has not been active for some time, or a process which has a low priority, or a process which is page faulting frequently, or a process which is taking up a large amount of memory in order to free up main memory for other processes, swapping the process back in later when more memory is available, or when the process has been unblocked and is no longer waiting for a resource.

  25. Question 25 of 99
    Question 25

    Which of the following need not necessarily be saved on a context switch between processes?
    [Gate CS 2000]

    Correct

    The TLB stores the recent translations of virtual memory to physical memory and can be called an address-translation cache.
    As the process is taken out from CPU so no need to store this information.

    Incorrect

    Correct option is 2.
    The TLB stores the recent translations of virtual memory to physical memory and can be called an address-translation cache.
    As the process is taken out from CPU so no need to store this information.

  26. Question 26 of 99
    Question 26

    The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently.

    P1() 
    { 
       C = B – 1; 
       B = 2*C;  
    }
    
    P2()
    {
       D = 2 * B;
       B = D - 1; 
    }
    

    The number of distinct values that B can possibly take after the execution is:
    [Gate CS 2015]

    Correct

    The possible ways concurrent processes can follow:
    C = B – 1; // C = 1
    B = 2*C; // B = 2
    D = 2 * B; // D = 4
    B = D – 1; // B = 3

    C = B – 1; // C = 1
    D = 2 * B; // D = 4
    B = D – 1; // B = 3
    B = 2*C; // B = 2

    C = B – 1; // C = 1
    D = 2 * B; // D = 4
    B = 2*C; // B = 2
    B = D – 1; // B = 3

    D = 2 * B; // D = 4
    C = B – 1; // C = 1
    B = 2*C; // B = 2
    B = D – 1; // B = 3

    D = 2 * B; // D = 4
    B = D – 1; // B = 3
    C = B – 1; // C = 2
    B = 2*C; // B = 4

    There are 3 different possible values of B: 2, 3 and 4.

    Incorrect

    Correct option is 1.
    The possible ways concurrent processes can follow:
    C = B – 1; // C = 1
    B = 2*C; // B = 2
    D = 2 * B; // D = 4
    B = D – 1; // B = 3

    C = B – 1; // C = 1
    D = 2 * B; // D = 4
    B = D – 1; // B = 3
    B = 2*C; // B = 2

    C = B – 1; // C = 1
    D = 2 * B; // D = 4
    B = 2*C; // B = 2
    B = D – 1; // B = 3

    D = 2 * B; // D = 4
    C = B – 1; // C = 1
    B = 2*C; // B = 2
    B = D – 1; // B = 3

    D = 2 * B; // D = 4
    B = D – 1; // B = 3
    C = B – 1; // C = 2
    B = 2*C; // B = 4

    There are 3 different possible values of B: 2, 3 and 4.

  27. Question 27 of 99
    Question 27

    Two processes X and Y need to access a critical section. Consider the following synchronization construct used by both the processes.

    Here, varP and varQ are shared variables and both are initialized to false. Which one of the following statements is true?

    Correct

    When both processes try to enter critical section simultaneously,both are allowed to do so since both shared variables varP and varQ are true.So, clearly there is NO mutual exclusion. Also, deadlock is prevented because mutual exclusion is one of the four conditions to be satisfied for deadlock to happen.

    Incorrect

    Correct option is 1.
    When both processes try to enter critical section simultaneously,both are allowed to do so since both shared variables varP and varQ are true.So, clearly there is NO mutual exclusion. Also, deadlock is prevented because mutual exclusion is one of the four conditions to be satisfied for deadlock to happen.

  28. Question 28 of 99
    Question 28

    In a certain operating system, deadlock prevention is attempted using the following scheme. Each process is assigned a unique timestamp, and is restarted with the same timestamp if killed. Let Ph be the process holding a resource R, Pr be a process requesting for the same resource R, and T(Ph) and T(Pr) be their timestamps respectively. The decision to wait or preempt one of the processes is based on the following algorithm.

     if T(Pr) < T(Ph)
    
         then kill Pr
    
    else wait
    

    Which one of the following is TRUE?
    [Gate IT 2004]

    Correct

    1. This scheme is making sure that the timestamp of requesting process is always lesser than holding process
    2. The process is restarted with same timestamp if killed and that timestamp can NOT be greater than the existing time stamp

    From point 1 and 2,it is clear that any new process entering having LESSER timestamp will be KILLED, => NO DEADLOCK.
    However, a new process with lower timestamp may have to wait infinitely because of its LOWER timestamp (as killed process will also have same timestamp ,as it was killed earlier) this leads to STARVATION.

    Incorrect

    Correct option is 1.

    1. This scheme is making sure that the timestamp of requesting process is always lesser than holding process
    2. The process is restarted with same timestamp if killed and that timestamp can NOT be greater than the existing time stamp

    From point 1 and 2,it is clear that any new process entering having LESSER timestamp will be KILLED, => NO DEADLOCK.
    However, a new process with lower timestamp may have to wait infinitely because of its LOWER timestamp (as killed process will also have same timestamp ,as it was killed earlier) this leads to STARVATION.

  29. Question 29 of 99
    Question 29

    A process executes the following segment of code :

     for(i = 1; i < = n; i++)
        fork (); 
    

    The number of new processes created is:

    Correct

    We can also use direct formula to get the number of child processes. With n fork statements, there are always 2n – 1 child processes. Also see this post for more details.

    Incorrect

    Correct option is 3.
    We can also use direct formula to get the number of child processes. With n fork statements, there are always 2n – 1 child processes. Also see this post for more details.

  30. Question 30 of 99
    Question 30

    The semaphore variables full, empty and mutex are initialized to 0, n and 1, respectively. Process P1 repeatedly adds one item at a time to a buffer of size n, and process P2 repeatedly removes one item at a time from the same buffer using the programs given below. In the programs, K, L, M and N are unspecified statements.
    P1:

    while (1) 
     {  K; 
        P(mutex); 
        Add an item to the buffer; 
        V(mutex);
        L; 
    } 
    

    P2

    while (1)
     {  M; 
        P(mutex); 
        Remove an item from the buffer; 
        V(mutex);     
        N; 
    } 
    

    The statements K, L, M and N are respectively:
    [Gate IT 2004]

    Correct

    It is a case of producer (P1) consumer (P2).
    Semaphore ‘full= 0′ => no item in the buffer.
    Semaphore ‘empty = n’ => buffer size is n maximum items can be produced without consuming any.
    In process P1,
    P(empty) => if there is no space in buffer then P1 can not produce more items. V(full) => one item has been added to the buffer.
    In process P2,
    P(full) => the buffer is empty then consumer can’t consume any item.
    V(empty) => a space is made available in the buffer after consumption of an item.

    Incorrect

    Correct option is 4.
    It is a case of producer (P1) consumer (P2).
    Semaphore ‘full= 0′ => no item in the buffer.
    Semaphore ‘empty = n’ => buffer size is n maximum items can be produced without consuming any.
    In process P1,
    P(empty) => if there is no space in buffer then P1 can not produce more items. V(full) => one item has been added to the buffer.
    In process P2,
    P(full) => the buffer is empty then consumer can’t consume any item.
    V(empty) => a space is made available in the buffer after consumption of an item.

  31. Question 31 of 99
    Question 31

    Consider the following two-process synchronization solution.

    Process 0                             Process 1                          
    
    Entry: loop while (turn == 1);        Entry: loop while (turn == 0);
           (critical section)                    (critical section)
           Exit: turn = 1;                       Exit turn = 0; 
    

    The shared variable turn is initialized to zero. Which one of the following is TRUE?
    [Gate CS 2016]

    Correct

    Process 1 can not go critical section as semaphore value is 0 initially and this process 1 can go CS only after process 0. So, progress requirement is not satisfied.

    Incorrect

    Correct option is 3.
    Process 1 can not go critical section as semaphore value is 0 initially and this process 1 can go CS only after process 0. So, progress requirement is not satisfied.

  32. Question 32 of 99
    Question 32

    Consider a non-negative counting semaphore S. The operation P(S) decrements S, and V(S) increments S. During an execution, 20 P(S) operations and 12 V(S) operations are issued in some order. The largest initial value of S for which at least one P(S) operation will remain blocked is ________.
    [Gate CS 2016]

    Correct

    At max 12 blocked processes may be released by 12 V(S) operations.
    =>20-12 = 8. So if S=8, after executing 20 P(S), 12 processes will be in blocked state. And these 12 processes can be released by 12 V(S) operations.
    Say, S=7,
    20 P(S) operations will block 13 processes in blocked state. 12 V(S) operation makes 12 more process to get chance for execution from blocked state. So one process will be left in the queue (blocked state).

    Incorrect

    Correct option is 1.
    At max 12 blocked processes may be released by 12 V(S) operations.
    =>20-12 = 8. So if S=8, after executing 20 P(S), 12 processes will be in blocked state. And these 12 processes can be released by 12 V(S) operations.
    Say, S=7,
    20 P(S) operations will block 13 processes in blocked state. 12 V(S) operation makes 12 more process to get chance for execution from blocked state. So one process will be left in the queue (blocked state).

  33. Question 33 of 99
    Question 33

    In the working-set strategy, which of the following is done by the operating system to prevent thrashing?

    1. It initiates another process if there are enough extra frames.
    2. It selects a process to suspend if the sum of the sizes of the working-sets exceeds the total number of available frames.

    [Gate IT 2006]

    Correct

    According to concept of thrashing,
    I is true, because to prevent thrashing system must provide processes with as many frames as they really need “right now”. If there is enough extra frames available, another process can be initiated.
    II is true, because The total demand say D, is the sum of the sizes of the working sets for all processes. If D exceeds the total number of available frames, then at least one process is thrashing, because there are not enough frames available to satisfy its minimum working set. If D is significantly less than the currently available frames, then new processes can be initiated.

    Incorrect

    Correct option is 4.
    According to concept of thrashing,
    I is true, because to prevent thrashing system must provide processes with as many frames as they really need “right now”. If there is enough extra frames available, another process can be initiated.
    II is true, because The total demand say D, is the sum of the sizes of the working sets for all processes. If D exceeds the total number of available frames, then at least one process is thrashing, because there are not enough frames available to satisfy its minimum working set. If D is significantly less than the currently available frames, then new processes can be initiated.

  34. Question 34 of 99
    Question 34

    Processes P1 and P2 use critical_flag in the following routine to achieve mutual exclusion. Assume that critical_flag is initialized to FALSE in the main program.

    get_exclusive_access ( ) { 
     if (critical _flag == FALSE) { 
       critical_flag = TRUE ; 
       critical_region () ; 
       critical_flag = FALSE; 
      } 
    } 
    

    Consider the following statements.
    i. It is possible for both P1 and P2 to access critical_region concurrently.
    ii. This may lead to a deadlock.
    Which of the following holds?
    [Gate IT 2007]

    Correct

    Say P1 starts first and executes statement 1, after that system context switches to P2 (before executing statement 2), and it enters inside if statement, since the flag is still false. So now both processes are in critical section!! so (i) is true. (ii) is false
    By no way it happens that flag is true and no process’ are inside the if clause, if someone enters the critical section, it will definitely make flag = false. So no deadlock.

    Incorrect

    Correct option is 3.
    Say P1 starts first and executes statement 1, after that system context switches to P2 (before executing statement 2), and it enters inside if statement, since the flag is still false. So now both processes are in critical section!! so (i) is true. (ii) is false
    By no way it happens that flag is true and no process’ are inside the if clause, if someone enters the critical section, it will definitely make flag = false. So no deadlock.

  35. Question 35 of 99
    Question 35

    The following is a code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores equipped with the standard P and V operations.

    semaphore S = 1, Q = 0; integer x; 
    producer:                        consumer: 
    while (true) do                    while (true) do 
    P(S);                              P(Q); 
    x = produce ();                    consume (x);
    V(Q);                              V(S); 
    done                               done 
    Which of the following is TRUE about the program above?
    Gate IT 2008
    Correct

    This is the case of strict alternative execution of producer consumer. First Producer will execute and then consumer as S=1 initially and Q=0. Producer can only execute when consumer executes and S becomes >0 again.
    Hence both will execute alternately.

    Incorrect

    Correct option is 4.
    This is the case of strict alternative execution of producer consumer. First Producer will execute and then consumer as S=1 initially and Q=0. Producer can only execute when consumer executes and S becomes >0 again.
    Hence both will execute alternately.The process can deadlock

  36. Question 36 of 99
    Question 36

    An operating system implements a policy that requires a process to release all resources before making a request for another resource. Select the TRUE statement from the following:
    Gate IT 2008

    Correct

    Starvation may occur, as a process may want other resource in addition to the resources in hand. In such situation it has to release all the resources. When this process attempts to acquire resources again, resources may not be available, and this situation may go indefinite. In other words there is no rules by which starvation situation may be avoided.
    Deadlock is not possible as hold and wait condition does not hold here.

    Incorrect

    Correct option is 2.
    Starvation may occur, as a process may want other resource in addition to the resources in hand. In such situation it has to release all the resources. When this process attempts to acquire resources again, resources may not be available, and this situation may go indefinite. In other words there is no rules by which starvation situation may be avoided.
    Deadlock is not possible as hold and wait condition does not hold here.Both starvation and deadlock can occur

  37. Question 37 of 99
    Question 37

    If the time-slice used in the round-robin scheduling policy is more than the maximum time required to execute any process, then the policy will
    Gate IT 2008

    Correct

    Round Robin executes processes in FCFS manner with a time slice. Round Robin becomes FCFS When this time slice becomes long enough such that a process completes within it.

    Incorrect

    Correct option is 3.
    Round Robin executes processes in FCFS manner with a time slice. Round Robin becomes FCFS When this time slice becomes long enough such that a process completes within it.

  38. Question 38 of 99
    Question 38

    Consider the following C code for process P1 and P2.

    a=4, b=0, c=0;
         P1                       P2
      if (a < 0)                b = 10;    
        c = b-a;                a = -3;
      else
        c = b+a;
    

    If the processes P1 and P2 executes concurrently (shared variables a, b and c), which of the following cannot be the value of ‘c’ after both processes complete?
    Gate 2017

    Correct

    P1 : Line 1,Line 3,Line 4 -> c = 0+4 =4
    P2 : Line 1,Line 2 and P1 :Line 1,Line 2 -> c = 10-(-3) = 13
    P1 : Line 1 , P2 :Line 1,Line 2 and P1 :Line 3,Line 4 -> c= 10+(-3) = 7
    So c can not have value 10.

    Incorrect

    Correct option is 3.
    P1 : Line 1,Line 3,Line 4 -> c = 0+4 =4
    P2 : Line 1,Line 2 and P1 :Line 1,Line 2 -> c = 10-(-3) = 13
    P1 : Line 1 , P2 :Line 1,Line 2 and P1 :Line 3,Line 4 -> c= 10+(-3) = 7
    So c can not have value 10.

  39. Question 39 of 99
    Question 39

    Which of the following actions is/are typically not performed by the operating system when switching context from process A to process B?

    Correct

    During context switch processes are asked to leave CPU not the memory. Processes are generally swapped out from memory to disk when they are suspended. Also, during context switch OS invalidates TLB so that the entries of swapped out process in TLB invalidated and TLB coincides with the currently executing processes.

    Incorrect

    Correct option is 3.
    During context switch processes are asked to leave CPU not the memory. Processes are generally swapped out from memory to disk when they are suspended. Also, during context switch OS invalidates TLB so that the entries of swapped out process in TLB invalidated and TLB coincides with the currently executing processes.

  40. Question 40 of 99
    Question 40

    In a computer system where the ‘best-fit’ algorithm is used for allocating ‘jobs’ to ‘memory partitions’, the following situation was encountered:

    When will the 20K job complete?
    Gate CS 1998]

    Correct

    Best fit algorithm allocates the process to a partition such that the left over space of that partition is minimum among all free available partition blocks.
    1. First 2k come and fit into the partition of 2k and run for 4 unit of time
    2. Then comes 14k and it fit into the partition of 20k and run for 10 units of time.
    3. Process comes of size 3k and fit into the portion 4k and runs for 2 units of the time
    4. Process of size 6k come and fit to the 8k partition and runs for 1 unit of time.
    5. Process of size 10k comes and fit into portion 20k runs for 1 unit of time
    6. Lastly 20k comes and fit into 20k portion and run for 8 units of time
    So total completion time for 20k job = (10+1+8) = 19 unit of time.
    It has to wait for 20k block to get emptied, and before it processes 2 (10 units of time)and 5 (1 units of time)need to be finished.

    Incorrect

    Correct option is 2.
    Best fit algorithm allocates the process to a partition such that the left over space of that partition is minimum among all free available partition blocks.
    1. First 2k come and fit into the partition of 2k and run for 4 unit of time
    2. Then comes 14k and it fit into the partition of 20k and run for 10 units of time.
    3. Process comes of size 3k and fit into the portion 4k and runs for 2 units of the time
    4. Process of size 6k come and fit to the 8k partition and runs for 1 unit of time.
    5. Process of size 10k comes and fit into portion 20k runs for 1 unit of time
    6. Lastly 20k comes and fit into 20k portion and run for 8 units of time
    So total completion time for 20k job = (10+1+8) = 19 unit of time.
    It has to wait for 20k block to get emptied, and before it processes 2 (10 units of time)and 5 (1 units of time)need to be finished.

  41. Question 41 of 99
    Question 41

    The process state transition diagram in below figure is representative of which type of system:

    [Gate CS 1996]

    Correct

    In a batch processing system processes are executed sequentially.
    In a non-preemptive system a process cannot transit from running to ready state.
    In a uni-programmed system blocked process will go to running instead of ready state.
    So, the shown system is a preemptive system.

    Incorrect

    Correct option is 2.
    In a batch processing system processes are executed sequentially.
    In a non-preemptive system a process cannot transit from running to ready state.
    In a uni-programmed system blocked process will go to running instead of ready state.
    So, the shown system is a preemptive system.

  42. Question 42 of 99
    Question 42

    Which of the following option is False?
    [Gate CS 2018]

    Correct

    Threads are called as light weight process, because threads of a process (a process can be devided into many threads) can share some resources like, PCB, shared variables and code section of the process. Hence overhead of processes is much more than that of threads.

    Incorrect

    Correct option is 2.
    Threads are called as light weight process, because threads of a process (a process can be devided into many threads) can share some resources like, PCB, shared variables and code section of the process. Hence overhead of processes is much more than that of threads.

  43. Question 43 of 99
    Question 43

    Which of the following is/are not shared by all the threads in a process?

    1. Program Counter
    2. Stack
    3. Registers
    4. Address space
    5. [Gate CS 2018]

    Correct

    Every thread has its own stack, register, and PC, Address space is shared by all threads for a process.

    Incorrect

    Correct option is 3.
    Every thread has its own stack, register, and PC, Address space is shared by all threads for a process.

  44. Question 44 of 99
    Question 44

    Consider the set of processes with arrival time(in milliseconds), CPU burst time (in milliseconds), and priority(0 is the highest priority) shown below. None of the processes have I/O burst time.
    Process Arrival Time Burst Time Priority
    P1 0 11 2
    P2 5 28 0
    P3 12 2 3
    P4 2 10 1
    P5 9 16 4
    The waiting time (in milliseconds) of process P1 using preemptive priority scheduling algorithm is ____.

    Correct

    | P1 | P4 | P2 | P4 | P1 | P3 | P5 |
    0 2 5 33 40 49 51 67

    So waiting time: 49 – 0 – 11 = 38

    Incorrect

    Correct option is 3.
    | P1 | P4 | P2 | P4 | P1 | P3 | P5 |
    0 2 5 33 40 49 51 67

    So waiting time: 49 – 0 – 11 = 38

  45. Question 45 of 99
    Question 45

    The following are some events that occur after a device controller issues an interrupt while process L is under execution.
    (P) The processor pushes the process status of L onto the control stack.
    (Q) The processor finishes the execution of the current instruction.
    (R) The processor executes the interrupt service routine.
    (S) The processor pops the process status of L from the control stack.
    (T) The processor loads the new PC value based on the interrupt.
    Which of the following is the correct order in the which the events above occur?
    [Gate CS 2018]

    Correct

    When an interrupt occurs, processor finishes currently executing instruction and saves the state and register values to control stack. Processor loads the interrupt service routine and after execution, processor loads new process to execute.

    Incorrect

    Correct option is 1.
    When an interrupt occurs, processor finishes currently executing instruction and saves the state and register values to control stack. Processor loads the interrupt service routine and after execution, processor loads new process to execute.

  46. Question 46 of 99
    Question 46

    Two atomic operations permissible on Semaphores are __________ and __________.
    [NET CS Nov 2017]

    Correct

    Wait () or P() and signal() or V() are the two operations could be performed on semaphores.

    Incorrect

    Correct option is 4.
    Wait () or P() and signal() or V() are the two operations could be performed on semaphores.

  47. Question 47 of 99
    Question 47

    Consider three CPU intensive processes, which require 10, 20, 30 units and arrive at times 0, 2, 6 respectively. How many context switches are needed if shortest remaining time first process scheduling algorithm is implemented? Context switch at 0 is included but context switch at end is ignored.
    ISRO 2017

    Correct

    | P0 | P1 | P2 |
    0 10 30 60
    Context switching happens at: 0, 10,and 30 (as last one is not considered)
    So total 3 context switching occurs.

    Incorrect

    Correct option is 3.
    | P0 | P1 | P2 |
    0 10 30 60
    Context switching happens at: 0, 10,and 30 (as last one is not considered)
    So total 3 context switching occurs.

  48. Question 48 of 99
    Question 48

    User level threads are threads that are visible to the programmer and are unknown to the kernel. The operating system kernel supports and manages kernel level threads. Three different types of models relate user and kernel level threads. Which of the following statements is/are true ?
    (a)
    (i) The Many – to – one model maps many user threads to one kernel thread
    (ii) The one – to – one model maps one user thread to one kernel thread
    (iii) The many – to – many model maps many user threads to smaller or equal kernel threads
    (b)
    (i) Many – to – one model maps many kernel threads to one user thread
    (ii) One – to – one model maps one kernel thread to one user thread
    (iii) Many – to – many model maps many kernel threads to smaller or equal user threads
    [NET Nov 2017]

    Correct

    Incorrect

    Correct option is 3.

  49. Question 49 of 99
    Question 49

    The Bounded buffer problem is also known as __________.
    [NET CS Nov 2017]

    Correct

    Producer Consumer problem in operating systems is a classical problem of bounded buffer problem.

    Incorrect

    Correct option is 1.
    Producer Consumer problem in operating systems is a classical problem of bounded buffer problem.

  50. Question 50 of 99
    Question 50

    What is the output of the following program?

    main( )
    {
      int a = 10;
      if ((fork ( ) == 0))
       a++;
      printf (“%dn”, a );
    } 
    [ISRO 2017]
    Correct

    When fork() is called a new child process is created.
    After fork() execution two processes exist: Parent process and the child process.
    In the parent process:
    fork() function returns pid of newly created child process(a non zero value)
    In the child process:
    fork() function returns 0.
    So, here after fork() execution in the parent process “if” condition will be false and hence a++ will not be executed.
    while in child process “if” condition will be true and hence a++ will be executed.
    So, in 10 will be printed by parent process and 11 will be printed by child process.
    Note:
    1. the order of printing of parent and child processes is random.
    2. execution of “a++” in child process will not affect value of “a” in parent process as the address space of both are completely different.

    Incorrect

    Correct option is 1.
    When fork() is called a new child process is created.
    After fork() execution two processes exist: Parent process and the child process.
    In the parent process:
    fork() function returns pid of newly created child process(a non zero value)
    In the child process:
    fork() function returns 0.
    So, here after fork() execution in the parent process “if” condition will be false and hence a++ will not be executed.
    while in child process “if” condition will be true and hence a++ will be executed.
    So, in 10 will be printed by parent process and 11 will be printed by child process.
    Note:
    1. the order of printing of parent and child processes is random.
    2. execution of “a++” in child process will not affect value of “a” in parent process as the address space of both are completely different.

  51. Question 51 of 99
    Question 51

    Mutual exclusion problem occurs:
    [ISRO 2017]

    Correct

    Mutual exclusion means: restricting other to use shared resources.

    Incorrect

    Correct option is 2.
    Mutual exclusion means: restricting other to use shared resources.

  52. Question 52 of 99
    Question 52

    A critical region
    [ISRO 2017]

    Correct

    Critical region is the piece of code which should be executed exclusively by one process only.

    Incorrect

    Correct option is 1.
    Critical region is the piece of code which should be executed exclusively by one process only.

  53. Question 53 of 99
    Question 53

    At particular time, the value of a counting semaphore is 10, it will become 7 after:
    (a) 3 V operations
    (b) 3 P operations
    (c) 5 V operations and 2 P operations
    (d) 2 V operations and 5 P operations
    Which of the following option is correct?
    [ISRO 2017]

    Correct

    P operation decrements value of semaphore by 1 and V operation increments value of semaphore by 1.

    Incorrect

    Correct option is 3.
    P operation decrements value of semaphore by 1 and V operation increments value of semaphore by 1.

  54. Question 54 of 99
    Question 54

    There are three processes P1, P2 and P3 sharing a semaphore for synchronizing a variable. Initial value of semaphore is one. Assume that negative value of semaphore tells us how many processes are waiting in queue. Processes access the semaphore in following order :
    (a) P2 needs to access
    (b) P1 needs to access
    (c) P3 needs to access
    (d) P2 exits critical section
    (e) P1 exits critical section
    The final value of semaphore will be :
    [NET CS 2017]

    Correct

    Initially S = 1
    P2 enters => S=0
    P1 => Blocked
    P3 => Blocked
    P2 exits => S=1
    P1 unblocked, enters => S=0
    P1 exits => S=1
    P3 unblocked, enters => S=0
    So finally S=0.

    Incorrect

    Correct option is 1.
    Initially S = 1
    P2 enters => S=0
    P1 => Blocked
    P3 => Blocked
    P2 exits => S=1
    P1 unblocked, enters => S=0
    P1 exits => S=1
    P3 unblocked, enters => S=0
    So finally S=0.

  55. Question 55 of 99
    Question 55

    At a particular time of computation the value of a counting semaphore is 7. Then 20 P operations and x V operations were completed on this semaphore. If the new value of semaphore is 5, x will be

    Correct

    S=7,
    20 P operations => S=-13
    x V operations => S=5=x-13
    => x-13 = 5
    => x=18

    Incorrect

    Correct option is 1.
    S=7,
    20 P operations => S=-13
    x V operations => S=5=x-13
    => x-13 = 5
    => x=18

  56. Question 56 of 99
    Question 56

    One of the disadvantages of user level threads compared to Kernel level threads is:
    [NET CS 2017]

    Correct

    Kernel is unaware of user level threads, and is unable to schedule user threads.

    Incorrect

    Correct option is 1.
    Kernel is unaware of user level threads, and is unable to schedule user threads.

  57. Question 57 of 99
    Question 57

    Names of some of the Operating Systems are given below: (a) MS-DOS (b) XENIX (c) OS/2 In the above list, following operating systems didn’t provide multiuser facility.
    [NET CS 2017]

    Correct

    None of these OS is mutiuser.
    MS-DOS is an operating system for x86-based personal computers by Microsoft. It doesn’t provide multi-user facility.
    XENIX is a version of the Unix operating system for various microcomputer platforms which is now discontinued, licensed by Microsoft from AT&T Corporation. It doesn’t provide multi-user facility.
    OS/2 is created by Microsoft and IBM. It is a series of computer operating systems and doesn’t provide multi-user facility.

    Incorrect

    Correct option is 4.
    None of these OS is mutiuser.
    MS-DOS is an operating system for x86-based personal computers by Microsoft. It doesn’t provide multi-user facility.
    XENIX is a version of the Unix operating system for various microcomputer platforms which is now discontinued, licensed by Microsoft from AT&T Corporation. It doesn’t provide multi-user facility.
    OS/2 is created by Microsoft and IBM. It is a series of computer operating systems and doesn’t provide multi-user facility.

  58. Question 58 of 99
    Question 58

    In a lottery scheduler with 40 tickets, how we will distribute the tickets among 4 processes and such that each process gets 10%, 5%, 60% and 25% respectively?

         P1   P2   P3   P4
    a)   12   4    70   30
    b)   7    5    20   10
    c)   4    2    24   10
    d)   8    5    40   30
    

    [ISRO 2015]

    Correct

    By looking at options it is clearly visible that only in option C) it becomes total number of resources 40 (4+2+24+10)
    Or, P1 gets 10 % and P2 gets 5% => P1 gets twice that of P2 => it is hold true only in option c)
    Or, Total are 40, 10% of 40 =4, 5% of 40 = 2, 60% of 40 is 24 and 25% of 40 =10

    Incorrect

    Correct option is 3.
    By looking at options it is clearly visible that only in option C) it becomes total number of resources 40 (4+2+24+10)
    Or, P1 gets 10 % and P2 gets 5% => P1 gets twice that of P2 => it is hold true only in option c)
    Or, Total are 40, 10% of 40 =4, 5% of 40 = 2, 60% of 40 is 24 and 25% of 40 =10

  59. Question 59 of 99
    Question 59

    Suppose a system contains n processes and system uses the round-robin algorithm for CPU scheduling then which data structure is best suited for ready queue of the process.

    Correct

    In round robin algorithm processes are executed in FCFS manner for allocated time slice once all the processes executed for once, cycle repeats again and this process goes on till all the processes completed.
    Whenever a new process arrives it is added to the queue at the end.
    So, Circular queue is the data structure suitable for RR.

    Incorrect

    Correct option is 3.
    In round robin algorithm processes are executed in FCFS manner for allocated time slice once all the processes executed for once, cycle repeats again and this process goes on till all the processes completed.
    Whenever a new process arrives it is added to the queue at the end.
    So, Circular queue is the data structure suitable for RR.

  60. Question 60 of 99
    Question 60

    Consider a system with seven processes A through G and six resources R through W. Resource ownership is as follows : process A holds R and wants T process B holds nothing but wants T process C holds nothing but wants S process D holds U and wants S & T process E holds T and wants V process F holds W and wants S process G holds V and wants U Is the system deadlocked ? If yes, ______ processes are deadlocked.

    Correct


    As shown in resource allocation graph, processes D, E, and G forms cycle and hence will be in deadlock state.

    Incorrect

    Correct option is 3.

    As shown in resource allocation graph, processes D, E, and G forms cycle and hence will be in deadlock state.

  61. Question 61 of 99
    Question 61

    Consider a system having ‘m’ resources of the same type. These resources are shared by three processes P1, P2 and P3 which have peak demands of 2, 5 and 7 resources respectively. For what value of ‘m’ deadlock will not occur ?

    Correct

    In worst case say all the processes acquire one resource less than its requirement, so the acquired resources are: 1+4+6=11. Now if any one of these gets 1 more resource that process will gets executed and releases the acquired resources. These released resources can be used by other process to finish.
    So, minimum value of m should be 12.

    Incorrect

    Correct option is 2.
    In worst case say all the processes acquire one resource less than its requirement, so the acquired resources are: 1+4+6=11. Now if any one of these gets 1 more resource that process will gets executed and releases the acquired resources. These released resources can be used by other process to finish.
    So, minimum value of m should be 12.
    Nearest best option is 13.

  62. Question 62 of 99
    Question 62

    An Operating System (OS) crashes on the average once in 30 days, that is, the Mean Time Between Failures (MTBF) = 30 days. When this happens, it takes 10 minutes to recover the OS, that is, the Mean Time To Repair (MTTR) = 10 minutes. The availability of the OS with these reliability figures is approximately :
    [NET 2016]

    Correct

    System crashes once in 30 days and need 10 minutes to get repaired.
    30 days => (30 ∗ 24 ∗ 60) minute
    Time system is not available = (10 / (30 ∗ 24 ∗ 60 )) ∗ 100 = 0.023%
    Availability = 100 – 0.023 = 99.97%

    Incorrect

    Correct option is 4.
    System crashes once in 30 days and need 10 minutes to get repaired.
    30 days => (30 ∗ 24 ∗ 60) minute
    Time system is not available = (10 / (30 ∗ 24 ∗ 60 )) ∗ 100 = 0.023%
    Availability = 100 – 0.023 = 99.97%

  63. Question 63 of 99
    Question 63

    Suppose there are four processes in execution with 12 instances of a Resource R in a system. The maximum need of each process and current allocation are given below:

    Process Max. Need Allocation
    P1 8 3
    P2 9 4
    P3 5 2
    P4 3 1

    With reference to current allocation, is system safe ? If so, what is the safe sequence ?

    Correct

    Total current allocation = (3+ 4+ 2+ 1)= 10.
    Total resources = 12
    Available resources after allocation =2.
    Current Need:
    P1: 5, P2: 5, P3: 3, P4: 2.
    So, P4 will run first and free 3 resources after execution. Which are sufficient for P3 So it will execute and do free 5 resources. Now P1 and P2 both require 5 resources each So we can execute any of them first.
    Option 3 is correct P4P3P1P2.

    Incorrect

    Correct option is 3.
    Total current allocation = (3+ 4+ 2+ 1)= 10.
    Total resources = 12
    Available resources after allocation =2.
    Current Need:
    P1: 5, P2: 5, P3: 3, P4: 2.
    So, P4 will run first and free 3 resources after execution. Which are sufficient for P3 So it will execute and do free 5 resources. Now P1 and P2 both require 5 resources each So we can execute any of them first.
    Option 3 is correct P4P3P1P2.

  64. Question 64 of 99
    Question 64

    Consider the following set of processes, with arrival times and the required CPU-burst times given in milliseconds.

    What is the sequence in which the processes are completed? Assume round robin scheduling with a time quantum of 2 milliseconds.
    [ISRO 2013]

    Process Arrival Time Burst Time
    P1 0 4 P2 2 2
    P3 3 1>/td>
    Correct

    | P1 | P2 | P3 | P1 |
    0 2 4 5 7
    So, the sequence of execution is: P1->P2->P3->P1

    Incorrect

    Correct option is 3.
    | P1 | P2 | P3 | P1 |
    0 2 4 5 7
    So, the sequence of execution is: P1->P2->P3->P1

  65. Question 65 of 99
    Question 65

    A CPU scheduling algorithm determines an order for the execution of its scheduled processes. Given ‘n’ processes to be scheduled on one processor, how many possible different schedules are there?
    [ISRO 2013]

    Correct

    For n processes:
    1st process has n ways to schedule
    2nd process has (n-1) ways to schedule [as 1 slot is already booked by 1st process
    3rd process has (n-2) ways to schedule
    and
    nth process has only 1 ways to schedule
    so, total ways are n.(n-1).(n-2)…….1 =>n!

    Incorrect

    Correct option is 3.
    For n processes:
    1st process has n ways to schedule
    2nd process has (n-1) ways to schedule [as 1 slot is already booked by 1st process
    3rd process has (n-2) ways to schedule
    and
    nth process has only 1 ways to schedule
    so, total ways are n.(n-1).(n-2)…….1 =>n!

  66. Question 66 of 99
    Question 66

    A starvation free job scheduling policy guarantees that no job indefinitely waits for a service. Which of the following job scheduling policies is starvation free?
    [ISRO 2013]

    Correct

    Starvation free policy must ensure that all the processes should get chance to execute. In round robin policy processes are executed in FCFS manner for the set time slice.

    Incorrect

    Correct option is 3.
    Starvation free policy must ensure that all the processes should get chance to execute. In round robin policy processes are executed in FCFS manner for the set time slice.

  67. Question 67 of 99
    Question 67

    The state of a process after it encounters an I/O instruction is
    [ISRO 2013]

    Correct

    A process shifted to waiting or blocked state when it encounters an I/O instruction while executing.

    Incorrect

    Correct option is 2.
    A process shifted to waiting or blocked state when it encounters an I/O instruction while executing.

  68. Question 68 of 99
    Question 68

    Which of the following strategy is employed for overcoming the priority inversion problem?
    [ISRO 2013]

    Correct

    Priority inversion is a scenario in scheduling when a higher priority process is indirectly preempted by a lower priority process, thereby inverting the relative priorities of the process. This problem can be eliminated by temporarily raising the priority of lower priority level process, so that the issue of a lower priority process preempt the higher priority process can be addressed.

    Incorrect

    Correct option is 1.
    Priority inversion is a scenario in scheduling when a higher priority process is indirectly preempted by a lower priority process, thereby inverting the relative priorities of the process. This problem can be eliminated by temporarily raising the priority of lower priority level process, so that the issue of a lower priority process preempt the higher priority process can be addressed.

  69. Question 69 of 99
    Question 69

    System calls are usually invoked by using:
    [NET CS 2015]

    Correct

    System calls are invoked using software interrupts also called “Trap”.
    Polling is the process where the computer or controlling device waits for an external device to check for its readiness or state, often with low-level hardware.
    Privileged instruction is an instruction (usually in machine code) that can be executed only by the operating system in a specific mode.
    In direct jump, the target address (i.e. its relative offset value) is encoded into the jump instruction itself.

    Incorrect

    Correct option is 3.
    System calls are invoked using software interrupts also called “Trap”.
    Polling is the process where the computer or controlling device waits for an external device to check for its readiness or state, often with low-level hardware.
    Privileged instruction is an instruction (usually in machine code) that can be executed only by the operating system in a specific mode.
    In direct jump, the target address (i.e. its relative offset value) is encoded into the jump instruction itself.

  70. Question 70 of 99
    Question 70

    A disk drive has 100 cylinders, numbered 0 to 99. Disk requests come to the disk driver for cylinders 12, 26, 24, 4, 42, 8 and 50 in that order. The driver is currently serving a request at cylinder 24. A seek takes 6 msec per cylinder moved. How much seek time is needed for shortest seek time first (SSTF) algorithm?
    [NET 2015]

    Correct

    Currently head is at 24 so the movement is as follows:-
    (24 -> 24) -> (24 ->26) -> (26 -> 12) -> (12 -> 8) -> (8 -> 4) -> (4 -> 42) -> (42 -> 50)
    So, total head movements = 0+2+14+4+4+38+8=70
    Total time = 70*6 = 420 msec = .42 sec

    Incorrect

    Correct option is 4.
    Currently head is at 24 so the movement is as follows:-
    (24 -> 24) -> (24 ->26) -> (26 -> 12) -> (12 -> 8) -> (8 -> 4) -> (4 -> 42) -> (42 -> 50)
    So, total head movements = 0+2+14+4+4+38+8=70
    Total time = 70*6 = 420 msec = .42 sec

  71. Question 71 of 99
    Question 71

    The following table shows the processes in the ready queue and time required for each process for completing its job.

    Process Time
    P1 10
    P2 5
    P3 20
    P4 8
    P5 15

    If round-robin scheduling with 5 ms is used what is the average waiting time of the processes in the queue?
    [ISRO 2011]

    Correct

    | P1 | P2 | P3 | P4 | P5 | P1 | P3 | P4 | P5 | P3 | P5 | P3 |
    0 5 10 15 20 25 30 35 38 43 48 53 58
    So,
    Waiting time of P1 = 20
    Waiting time of P2 = 5
    Waiting time of P3 = 10 + 15 + 8 + 5 = 38
    Waiting time of P4 = 15 + 15 = 30
    Waiting time of P5 = 20 + 13 + 5 = 38

    Average waiting time = (20 + 5 + 38 + 30 + 38)/5 = 131/5 = 26.2

    Incorrect

    Correct option is 2.
    | P1 | P2 | P3 | P4 | P5 | P1 | P3 | P4 | P5 | P3 | P5 | P3 |
    0 5 10 15 20 25 30 35 38 43 48 53 58
    So,
    Waiting time of P1 = 20
    Waiting time of P2 = 5
    Waiting time of P3 = 10 + 15 + 8 + 5 = 38
    Waiting time of P4 = 15 + 15 = 30
    Waiting time of P5 = 20 + 13 + 5 = 38

    Average waiting time = (20 + 5 + 38 + 30 + 38)/5 = 131/5 = 26.2

  72. Question 72 of 99
    Question 72

    Consider a system with twelve magnetic tape drives and three processes P1, P2 and P3. Process P1 requires maximum ten tape drives, process P2 may need as many as four tape drives and P3 may need upto nine tape drives. Suppose that at time t1, process P1 is holding five tape drives, process P2 is holding two tape drives and process P3 is holding three tape drives. At time t1, system is in:

    Correct

    Total resources = 12
    P1 requires = 10, holding = 5, need = 5
    P2 requires = 4, holding = 2, need = 2
    P3 requires = 9, holding = 3, need = 6
    available after allocation = 12 -(5+2+3) = 12-10 = 2
    The need of P2 can be fulfilled, so after its execution P2 will release all 4 resources.
    Now, the need of P1 and P3 can not be fulfilled.
    So, the system is in unsafe state.

    Incorrect

    Correct option is 2.
    Total resources = 12
    P1 requires = 10, holding = 5, need = 5
    P2 requires = 4, holding = 2, need = 2
    P3 requires = 9, holding = 3, need = 6
    available after allocation = 12 -(5+2+3) = 12-10 = 2
    The need of P2 can be fulfilled, so after its execution P2 will release all 4 resources.
    Now, the need of P1 and P3 can not be fulfilled.
    So, the system is in unsafe state.

  73. Question 73 of 99
    Question 73

    In an operating system, indivisibility of operation means:
    [NET CS 2015]

    Correct

    Indivisibility of operation means processor can not be preempted while executing an operation. Once a process starts its execution inside the processor cannot be suspended or stopped .

    Incorrect

    Correct option is 3.
    Indivisibility of operation means processor can not be preempted while executing an operation. Once a process starts its execution inside the processor cannot be suspended or stopped .

  74. Question 74 of 99
    Question 74

    There are three processes in the ready queue. When the currently running process requests for I/O how many process switches take place?
    [ISRO 2011]

    Correct

    Context switching is the procedure of storing the state of an active process for the CPU when it has to start executing a new one.
    For example, process A with its address space and stack is currently being executed by the CPU and there is a system call to jump to a higher priority process B;
    the CPU needs to remember the current state of the process A so that it can suspend its operation, begin executing the new process B and when done, return to its previously executing process A
    Only one context switch process happened

    Incorrect

    Correct option is 1.
    Context switching is the procedure of storing the state of an active process for the CPU when it has to start executing a new one.
    For example, process A with its address space and stack is currently being executed by the CPU and there is a system call to jump to a higher priority process B;
    the CPU needs to remember the current state of the process A so that it can suspend its operation, begin executing the new process B and when done, return to its previously executing process A
    Only one context switch process happened

  75. Question 75 of 99
    Question 75

    Which is the correct definition of a valid process transition in an operating system?
    [ISRO CS 2009]

    Correct

    Wake up -> Blocked to Ready
    Dispatch -> Ready to Running
    Block -> Running to Blocked
    Timer Out -> Running to Ready

    Incorrect

    Correct option is 2.
    Wake up -> Blocked to Ready
    Dispatch -> Ready to Running
    Block -> Running to Blocked
    Timer Out -> Running to Ready

  76. Question 76 of 99
    Question 76

    The correct matching of the following pairs is

    (A) Disk check              (1) Roundrobin
    (B) Batch processing        (2) Scan
    (C) Time sharing            (3) LIFO
    (D) Stack operation         (4) FIFO
    
    Correct

    Incorrect

    Correct option is 4.

  77. Question 77 of 99
    Question 77

    Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.
    [ISRO 2009]

    Correct

    | P1 | P2 | P3 |
    0 10 30 60
    Total context switch = 2 (at 10 and 30)

    Incorrect

    Correct option is 2.
    | P1 | P2 | P3 |
    0 10 30 60
    Total context switch = 2 (at 10 and 30)

  78. Question 78 of 99
    Question 78

    Consider a set of 5 processes whose arrival time, CPU time needed and the priority are given below:

    Process       Arrival Time   CPU Time Needed     Priority
                  (in ms)
    P1              0             10                 5
    P2              0             5                  2
    P3              2             3                  1
    P4              5             20                 4
    P5              10            2                  3
    

    (smaller the number, higher the priority) If the CPU scheduling policy is priority scheduling without preemption, the average waiting time will be
    [ISRO CS 2009]

    Correct

    | P2 | P3 | P4 | P5 | P1 |
    0 5 8 28 30 40
    Average Waiting Time = (30 + 3 + 3 + 18)/ 5 = 10.8

    Incorrect

    Correct option is 3.
    | P2 | P3 | P4 | P5 | P1 |
    0 5 8 28 30 40
    Average Waiting Time = (30 + 3 + 3 + 18)/ 5 = 10.8

  79. Question 79 of 99
    Question 79

    Process is:
    [ISRO CS 2009]

    Correct

    A process is termed as a program in execution. Whenever a program needs to be executed, its process image is created inside the main memory and is placed in the ready queue. Later CPU is assigned to the process and it starts its execution.

    Incorrect

    Correct option is 3.
    A process is termed as a program in execution. Whenever a program needs to be executed, its process image is created inside the main memory and is placed in the ready queue. Later CPU is assigned to the process and it starts its execution.

  80. Question 80 of 99
    Question 80

    Four jobs to be executed on a single processor system arrive at time 0 in the order A, B, C, D . Their burst CPU time requirements are 4, 1, 8, 1 time units respectively. The completion time of A under round robin scheduling with time slice of one time unit is
    [ISRO 2008]

    Correct

    The order of execution of the processes using round robin algorithm with time quanta = 1 is:
    | A | B | C | D | A | C | A | C | A |
    0 1 2 3 4 5 6 7 8 9
    i.e, after 8 context switches, A finally completes its execution in 9 units.

    Incorrect

    Correct option is 4.
    The order of execution of the processes using round robin algorithm with time quanta = 1 is:
    | A | B | C | D | A | C | A | C | A |
    0 1 2 3 4 5 6 7 8 9
    i.e, after 8 context switches, A finally completes its execution in 9 units.

  81. Question 81 of 99
    Question 81

    Which of the following need not necessarily be saved on a context switch between processes? [ISRO CS 2008]

    Correct

    Explanation
    The values stored in registers, stack pointers and program counters are saved on context switch between the processes so as to resume the execution of the process. There’s no need of saving the contents of TLB as the contents TLB is used to speed up the execution and it stores it is invalidated after each context switch.
    Hence, the correct option is (B).

    Incorrect

    The Correct option is – B.
    The values stored in registers, stack pointers and program counters are saved on context switch between the processes so as to resume the execution of the process. There’s no need of saving the contents of TLB as the contents TLB is used to speed up the execution and it stores it is invalidated after each context switch.
    Hence, the correct option is (B).

  82. Question 82 of 99
    Question 82

    With Round-Robin CPU scheduling in a time shared system – [ISRO CS 2008]

    Correct

    If time quantum is very large, so that the time quantum is larger then the execution time of the process with largest execution time, then the processes scheduling happens according to FCFS.
    Hence, the correct option is (A).

    Incorrect

    The correct option is (A).
    If time quantum is very large, so that the time quantum is larger then the execution time of the process with largest execution time, then the processes scheduling happens according to FCFS.

  83. Question 83 of 99
    Question 83

    What is the name of the operating system that reads and reacts in terms of operating system? [ISRO CS 2008]

    Correct

    A real-time operating system is an operating system that guarantees to process events or data by a specific moment in time.
    Hence, the correct option is (C).

    Incorrect

    The correct option is (C).
    A real-time operating system is an operating system that guarantees to process events or data by a specific moment in time.

  84. Question 84 of 99
    Question 84

    Fork is: [ISRO CS 2008]

    Correct

    fork() creates a new process by duplicating the calling process, The new process, referred to as child, is an exact duplicate of the calling process, referred to as parent, except for the following : The child has its own unique process ID, and this PID does not match the ID of any existing process group.
    As the process calling the fork() is the parent process (created the child process), the child’s parent process ID is the same as the parent’s process ID. The child does not inherit its parent’s memory locks and semaphore adjustments. The child does not inherit outstanding asynchronous I/O operations from its parent nor does it inherit any asynchronous I/O contexts from its parent.
    Hence, the correct option is (D).

    Incorrect

    The correct option is (D).
    fork() creates a new process by duplicating the calling process, The new process, referred to as child, is an exact duplicate of the calling process, referred to as parent, except for the following : The child has its own unique process ID, and this PID does not match the ID of any existing process group.
    As the process calling the fork() is the parent process (created the child process), the child’s parent process ID is the same as the parent’s process ID. The child does not inherit its parent’s memory locks and semaphore adjustments. The child does not inherit outstanding asynchronous I/O operations from its parent nor does it inherit any asynchronous I/O contexts from its parent.

  85. Question 85 of 99
    Question 85

    The performance of Round Robin algorithm depends heavily on [ISRO CS 2008]

    Correct

    In Round Robin algorithm, it is very important to choose the time quantum very carefully as smaller the time quantum value, more the context switches thereby reducing the efficiency of the CPU and the larger time quantum value makes the round robin algorithm as FCFS algorithm.
    Hence, the correct option is (D).

    Incorrect

    The correct option is (D).In Round Robin algorithm, it is very important to choose the time quantum very carefully as smaller the time quantum value, more the context switches thereby reducing the efficiency of the CPU and the larger time quantum value makes the round robin algorithm as FCFS algorithm.

  86. Question 86 of 99
    Question 86

    Match the following:
    List – I List – II
    (a) Spooling (i) Allows several jobs in memory to improve CPU utilization
    (b) Multiprogramming (ii) Access to shared resources among geographically dispersed computers in a transparent way
    (c)Time sharing (iii) Overlapping I/O and computations
    (d)Distributed computing (iv) Allows many users to share a computer simultaneously by switching processor frequently

    codes:
    (a) (b) (c) (d)
    (1) (iii) (i) (ii) (iv)
    (2) (iii) (i) (iv) (ii)
    (3) (iv) (iii) (ii) (i)
    (4) (ii) (iii) (iv) (i)

    Correct

    Spooling provides Overlapping I/O and computations.
    Multiprogramming allows several jobs in the main memory at a time to improve CPU utilization.
    Time sharing allows many users to share a computer simultaneously by switching processor frequently.
    Distributed computing accesses to shared resources among geographically dispersed computers in a transparent way.
    Hence, the correct option is (B).

    Incorrect

    he correct option is (B).
    Spooling provides Overlapping I/O and computations.
    Multiprogramming allows several jobs in the main memory at a time to improve CPU utilization.
    Time sharing allows many users to share a computer simultaneously by switching processor frequently.
    Distributed computing accesses to shared resources among geographically dispersed computers in a transparent way.

  87. Question 87 of 99
    Question 87

    Dining Philosopher’s problem is a: [UGC NET CS 2015 June – Paper III]

    Correct

    Dining Philosopher’s problem is a Classical IPC problem.
    Hence, the correct option is (B).

    Incorrect

    The correct option is (B).
    Dining Philosopher’s problem is a Classical IPC problem.

  88. Question 88 of 99
    Question 88

    Consider a set of n tasks with known runtimes r1, r2….rn to be run on a uniprocessor machine. Which of the following processor scheduling algorithms will result in the maximum throughput? [ISRO CS 2007]

    Correct

    Throughput means total number of tasks executed per unit time i.e. sum of waiting time and burst time. Shortest job first scheduling is a scheduling policy that selects the waiting process with the smallest execution time to execute next. Thus, in shortest job first scheduling, shortest jobs are executed first. This means small small processes will be executed first hence the number of processes executed in a period will be high.
    Hence, the correct option is (B).

    Incorrect

    Throughput means total number of tasks executed per unit time i.e. sum of waiting time and burst time. Shortest job first scheduling is a scheduling policy that selects the waiting process with the smallest execution time to execute next. Thus, in shortest job first scheduling, shortest jobs are executed first. This means small small processes will be executed first hence the number of processes executed in a period will be high.
    Hence, the correct option is (B).

  89. Question 89 of 99
    Question 89

    Round Robin schedule is essentially the pre-emptive version of [ISRO CS 2007]

    Correct

    When FIFO is implemented with preemption, it acts like a round-robin algorithm.
    Hence, the correct option is (A).

    Incorrect

    When FIFO is implemented with preemption, it acts like a round-robin algorithm.
    Hence, the correct option is (A).

  90. Question 90 of 99
    Question 90

    A task in a blocked state: [ISRO CS 2007]

    Correct

    A process is in Waiting or Blocked state, when a it has requested for some input/output resource and is waiting for the resource.
    Hence, the correct option is (D).

    Incorrect

    A process is in Waiting or Blocked state, when a it has requested for some input/output resource and is waiting for the resource.
    Hence, the correct option is (D).

  91. Question 91 of 99
    Question 91

    On a system using non-preemptive scheduling, processes with expected run times of 5, 18, 9 and 12 are in the ready queue. In what order should they be run to minimize wait time? [ISRO cs 2007]

    Correct

    With SJF process scheduling algorithm the overall waiting time is minimum. So, here the execution order of given processes should be 5, 9, 12, 18.
    Hence, the correct option is (B).

    Incorrect

    With SJF process scheduling algorithm the overall waiting time is minimum. So, here the execution order of given processes should be 5, 9, 12, 18.
    Hence, the correct option is (B).

  92. Question 92 of 99
    Question 92

    Feedback queues [ISRO CS 2007]

    Correct

    Multilevel Feedback Queue Scheduling (MLFQ) is dynamic in nature that,it keep analyzing the behavior (time of execution) of processes and according to which it changes its priority of execution of processes.
    Hence, the correct option is option (C).

    Incorrect

    Multilevel Feedback Queue Scheduling (MLFQ) is dynamic in nature that,it keep analyzing the behavior (time of execution) of processes and according to which it changes its priority of execution of processes.
    Hence, the correct option is option (C).

  93. Question 93 of 99
    Question 93

    Which of the following conditions does not hold good for a solution to a critical section problem ? [UGC NET CS 2014 DEC II]

    Correct

    In Critical section problem:
    No assumptions may be made about speeds or the number of CPUs.
    No two processes may be simultaneously inside their critical sections.
    Processes running outside its critical section can’t block other processes getting enter into critical section.
    Processes do not wait forever to enter its critical section.
    Hence, the correct option is (C).

    Incorrect

    The correct option is (C).
    In Critical section problem:
    No assumptions may be made about speeds or the number of CPUs.
    No two processes may be simultaneously inside their critical sections.
    Processes running outside its critical section can’t block other processes getting enter into critical section.
    Processes do not wait forever to enter its critical section.

  94. Question 94 of 99
    Question 94

    For switching from a CPU user mode to the supervisor mode following type of interrupt is most appropriate [UGC NET CS 2014 DEC III]

    Correct

    For switching from a CPU user mode to the supervisor mode Software interrupts occurs. Software interrupts are internal interrupts triggered by some software instruction whereas external interrupts are caused by some hardware module.
    Hence, the correct option is (C).

    Incorrect

    The correct option is (C).
    For switching from a CPU user mode to the supervisor mode Software interrupts occurs. Software interrupts are internal interrupts triggered by some software instruction whereas external interrupts are caused by some hardware module.

  95. Question 95 of 99
    Question 95

    In a dot matrix printer the time to print a character is 6 m.sec., time to space in between characters is 2 m.sec., and the number of characters in a line are 200. The printing speed of the dot matrix printer in characters per second and the time to print a character line are given by which of the following options? [UGC NET CS 2014 DEC III]

    Correct

    Total no of characters = 200 (each character having one space)
    Time taken to print one character = 6 ms;
    Time taken to print one space = 2 ms.
    Character printing = 200 * 6 = 1200 ms
    Space printing = 200 * 2 = 400 ms
    Total printing time = 1200 + 400 = 1600 ms = 1.6 sec.
    The printing speed of the dot matrix printer in characters per second = 200 / 1.6 = 125 characters/sec. Hence, the correct option is (E).

    Incorrect

    The correct option is (E).
    Total no of characters = 200 (each character having one space)
    Time taken to print one character = 6 ms;
    Time taken to print one space = 2 ms.
    Character printing = 200 * 6 = 1200 ms
    Space printing = 200 * 2 = 400 ms
    Total printing time = 1200 + 400 = 1600 ms = 1.6 sec.
    The printing speed of the dot matrix printer in characters per second = 200 / 1.6 = 125 characters/sec.

  96. Question 96 of 99
    Question 96

    Monitor is an Interprocess Communication (IPC) technique which can be described as [UGC NET 2014 CS DEC III]

    Correct

    Monitor is an Interprocess Communication (IPC) technique which can be described as – higher level synchronization primitive and is a collection of procedures, variables, and data structures grouped together in a special package.
    Hence, the correct option is (A).

    Incorrect

    The correct option is (A).
    Monitor is an Interprocess Communication (IPC) technique which can be described as – higher level synchronization primitive and is a collection of procedures, variables, and data structures grouped together in a special package.

  97. Question 97 of 99
    Question 97

    The following C program

    main()
    {
    fork() ; fork() ; printf ("yes");
    }

    If we execute this core segment, how many times the string yes will be printed ? [ISRO CS 2018]

    Correct

    Number of times YES printed is equal to number of processes created.
    Total Number of Processes = 2n, where n is number of fork system calls.
    So here n = 2, 22 = 4

    fork ();   // Line 1
    fork ();   // Line 2
    
           P1      
        /     \     
      P1      C1    
     /  \    /  \   
    P1  C2  C1  C3   
    

    So, there are total 4 processes (3 new child processes and one original process).
    Hence, the correct option is (C).

    Incorrect

    The correct option is (C).
    Number of times YES printed is equal to number of processes created.
    Total Number of Processes = 2n, where n is number of fork system calls.
    So here n = 2, 22 = 4

    fork ();   // Line 1
    fork ();   // Line 2
    
           P1      
        /     \     
      P1      C1    
     /  \    /  \   
    P1  C2  C1  C3   
    

    So, there are total 4 processes (3 new child processes and one original process).

  98. Question 98 of 99
    Question 98

    Here are the two concurrent process P1, P2 with respective codes: P1 code:

    while (true) // infinite condition
    {
    A :____;
    printf("%d", 1);
    printf("%d", 1);
    B:____;
    }

    P2 code:

    while (true) // infinite condition
    {
    C:____;
    printf("%d", 0);
    printf("%d", 0);
    D:____;
    }

    What should be the binary semaphore operation on A,B,C,D respectively and what must be the intial values of semaphore M,N inorder to get the output 110011001100….? Where P is down and V is up operation respectively.

    Correct

    Incorrect

  99. Question 99 of 99
    Question 99

    At a particular time of computation, the value of a counting semaphore is 10. Then 12 P operations and “x” V operations were performed on this semaphore. If the final value of semaphore is 7, x will be: [UGC NET CS 2018 JULY II]

    Correct

    Initially the value of a counting semaphore is 10. Now 12 P operation are performed.
    Counting semaphore value = -2.
    “x” V operations were performed on this semaphore and final value of counting semaphore = 7
    i.e x + (-2) = 7 x = 9.
    Hence, the correct option is (C).

    Incorrect

    The correct option is (C).
    Initially the value of a counting semaphore is 10. Now 12 P operation are performed.
    Counting semaphore value = -2.
    “x” V operations were performed on this semaphore and final value of counting semaphore = 7
    i.e x + (-2) = 7 x = 9.

Exit mobile version