Loading

SET 6


  Question 1

What is the swap space in the disk used for?

A : Saving temporary html pages
B : Saving process data
C : Storing the super-block
D : Storing device drivers


  •  
    .

     Correct answer is :B

     Solution :
      Swap space is typically used to store process data.

  •   Question 2

    Increasing the RAM of a computer typically improves performance because:

    A : Virtual memory increases
    B : Larger RAMs are faster
    C : Fewer page faults occur
    D : Fewer segmentation faults occur


  •  
    .

     Correct answer is :C

     Solution :
      When RAM size is bigger, the page table would have more entries of pages, hence less number of page faults.

  •   Question 3

    Consider a disk drive with the following specifications: 16 surfaces, 512 tracks/surface, 512 sectors/track, 1 KB/sector, rotation speed 3000 rpm. The disk is operated in cycle stealing mode whereby whenever one byte word is ready it is sent to memory; similarly, for writing, the disk interface reads a 4 byte word from the memory in each DMA cycle. Memory cycle time is 40 nsec. The maximum percentage of time that the CPU gets blocked during DMA operation is:

    A : 10
    B : 25
    C : 40
    D : 50


  •  
    .

     Correct answer is :B

     Solution :
      Time takes for 1 rotation = 60/3000 It reads 512*1024 Bytes in one rotation. Time taken to read 4 bytes = 153 ns 153 is approximately 4 cycles (160ns) Percentage of time CPU gets blocked = 40*100/160 = 25

  •   Question 4

    Suppose n processes, P1, …. Pn share m identical resource units, which can be reserved and released one at a time. The maximum resource requirement of process Pi is Si, where Si > 0. Which one of the following is a sufficient condition for ensuring that deadlock does not occur?



    A : A
    B : B
    C : C
    D : D


  •  
    .

     Correct answer is :C

     Solution :
      In the extreme condition, all processes acquire Si-1 resources and need 1 more resource. So opion c must be true to make sure that deadlock never occurs.

  •   Question 5

    Consider the following code fragment:
    if (fork() == 0)
    {
    a = a + 5; printf(“%d,%d\n”, a, &a);
    }
    else { a = a –5; printf(“%d, %d\n”, 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?


    A : u = x + 10 and v = y
    B : u = x + 10 and v != y
    C : u + 10 = x and v = y
    D : u + 10 = x and v != y


  •  
    .

     Correct answer is :C

     Solution :
      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

  •   Question 6

    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.

    A : 1
    B : 2
    C : 3
    D : 4


  •  
    .

     Correct answer is :B

     Solution :
      Let three process be P0, P1 and P2 with arrival times 0, 2 and 6 respectively and CPU burst times 10, 20 and 30 respectively. At time 0, P0 is the only available process so it runs. At time 2, P1 arrives, but P0 has the shortest remaining time, so it continues. At time 6, P2 arrives, but P0 has the shortest remaining time, so it continues. At time 10, P1 is scheduled as it is the shortest remaining time process. At time 30, P2 is scheduled. Only two context switches are needed. P0 to P1 and P1 t

  •   Question 7

    A CPU has a cache with block size 64 bytes. The main memory has k banks, each bank being c bytes wide. Consecutive c - byte chunks are mapped on consecutive banks with wrap-around. All the k banks can be accessed in parallel, but two accesses to the same bank must be serialized. A cache block access may involve multiple iterations of parallel bank accesses depending on the amount of data obtained by accessing all the k banks in parallel. Each iteration requires decoding the bank numbers to be accessed in parallel and this takes. k/2 ns The latency of one bank access is 80 ns. If c = 2 and k = 24, the latency of retrieving a cache block starting at address zero from main memory is:

    A : 92ns
    B : 104ns
    C : 172ns
    D : 184ns


  •  
    .

     Correct answer is :D

     Solution :
      Size of cache block=64B
    No. of main memory banks K=24
    Size of each bank C=2B
    So time taken for parallel access
    T=decoding time +latency time T=(K/2)+latency =12+80=92 ns
    But C=2 for accesses =2*92=184ns So (D) is correct option

  •   Question 8

    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?


    A : The implementation may not work if context switching is disabled in P
    B : Instead of using fetch-and –set, a pair of normal load/store can be used
    C : The implementation of V is wrong
    D : The code does not implement a binary semaphore


  •  
    .

     Correct answer is :A

     Solution :
      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().

  •   Question 9

    A CPU generates 32-bit virtual addresses. The page size is 4 KB. The processor has a translation look-aside buffer (TLB) which can hold a total of 128 page table entries and is 4-way set associative. The minimum size of the TLB tag is:

    A : 11bits
    B : 13bits
    C : 15bits
    D : 20bits


  •  
    .

     Correct answer is :C

     Solution :
      Size of a page = 4KB = 2^12
    Total number of bits needed to address a page frame = 32 – 12 = 20
    If there are ‘n’ cache lines in a set, the cache placement is called n-way set associative. Since TLB is 4 way set associative and can hold total 128 (2^7) page table entries, number of sets in cache = 2^7/4 = 2^5. So 5 bits are needed to address a set, and 15 (20 – 5) bits are needed for tag.

  •   Question 10

    A computer system supports 32-bit virtual addresses as well as 32-bit physical addresses. Since the virtual address space is of the same size as the physical address space, the operating system designers decide to get rid of the virtual memory entirely. Which one of the following is true?

    A : Efficient implementation of multi-user support is no longer possible
    B : The processor cache organization can be made more efficient now
    C : Hardware support for memory management is no longer needed
    D : CPU scheduling can be made more efficient now


  •  
    .

     Correct answer is :C

     Solution :
      For supporting virtual memory, special hardware support is needed from Memory Management Unit. Since operating system designers decide to get rid of the virtual memory entirely, hardware support for memory management is no longer needed

  •   Question 11

    Consider three processes (process id 0, 1, 2 respectively) with compute time bursts 2, 4 and 8 time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF ties are broken by giving priority to the process with the lowest process id. The average turn around time is:

    A : 13units
    B : 14units
    C : 15units
    D : 16units


  •  
    .

     Correct answer is :A

     Solution :
      Let the processes be p0, p1 and p2. These processes will be executed in following order.
      p2  p1  p2  p1  p2  p0  p1   p2   p0   p1   p2
    0   4   5   6   7   8   9   10    11   12   13   14 
    

    Turn around time of a process is total time between submission of the process and its completion.
    Turn around time of p0 = 12 (12-0)
    Turn around time of p1 = 13 (13-0)
    Turn around time of p2 = 14 (14-0)
    Average turn around time is (12+13+14)/3 = 13.

  •   Question 12

    Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units, respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time doing computation, and the last 10% of time doing I/O again. The operating system uses a shortest remaining compute time first scheduling algorithm and schedules a new process either when the running process gets blocked on I/O or when the running process finishes its compute burst. Assume that all

    A : 0%
    B : 10.6%
    C : 30.0%
    D : 89.4%


  •  
    .

     Correct answer is :B

     Solution :
      Let three processes be p0, p1 and p2. Their execution time is 10, 20 and 30 respectively. p0 spends first 2 time units in I/O, 7 units of CPU time and finally 1 unit in I/O. p1 spends first 4 units in I/O, 14 units of CPU time and finally 2 units in I/O. p2 spends first 6 units in I/O, 21 units of CPU time and finally 3 units in I/O.
     idle   p0    p1     p2    idle
    0    2     9     23     44     47
    

    Total time spent = 47
    Idle time = 2 + 3 = 5
    Percentage of idle

  •   Question 13

    Consider the following snapshot of a system running n processes. Process i is holding Xi instances of a resource R, 1 <= i <= n. currently, all instances of R are occupied. Further, for all i, process i has placed a request for an additional Yi instances while holding the Xi instances it already has. There are exactly two processes p and q such that Yp = Yq = 0. Which one of the following can serve as a necessary condition to guarantee that the system is not approaching a deadlock?

    A : min (Xp, Xq) < max (Yk) where k != p and k != q
    B : Xp + Xq >= min (Yk) where k != p and k != q
    C : max (Xp, Xq) > 1
    D : min (Xp, Xq) > 1


  •  
    .

     Correct answer is :B

     Solution :
      Since both p and q don’t need additional resources, they both can finish and release Xp + Xq resources without asking for any additional resource. If the resources released by p and q are sufficient for another process waiting for Yk resources, then system is not approaching deadlock.
    Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above

  •   Question 14

    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) {
    1:   P(S);
    2:   process_arrived++;
    3.   V(S);
    4:   while (process_arrived !=3);
    5:   P(S);
    6:   process_left++;
    7:   if (process_left==3) {
    8:      process_arrived = 0;
    9:      process_left = 0;
    10:  }
    11:  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. The above implementation of barrier is incorrect. Which one of the following is true?


    A : The barrier implementation is wrong due to the use of binary semaphore S
    B : The barrier implementation may lead to a deadlock if two barrier in invocations are used in immediat
    C : Lines 6 to 10 need not be inside a critical section
    D : The barrier implementation is correct if there are only two processes instead of three.


  •  
    .

     Correct answer is :B

     Solution :
      It is possible that process_arrived becomes greater than 3. It will not be possible for process arrived to become 3 again, hence deadlock.

  •   Question 15

    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) {
    1:   P(S);
    2:   process_arrived++;
    3.   V(S);
    4:   while (process_arrived !=3);
    5:   P(S);
    6:   process_left++;
    7:   if (process_left==3) {
    8:      process_arrived = 0;
    9:      process_left = 0;
    10:  }
    11:  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?


    A : Lines 6 to 10 are simply replaced by process_arrived--
    B : At the beginning of the barrier the first process to enter the barrier waits until process_arrived b
    C : Context switch is disabled at the beginning of the barrier and re-enabled at the end.
    D : The variable process_left is made private instead of shared


  •  
    .

     Correct answer is :C


  • MY REPORT
    TOTAL = 15
    ANSWERED =
    CORRECT / TOTAL = /15
    POSITIVE SCORE =
    NEGATIVE SCORE =
    FINAL SCORE =