Operating systems miscellaneous


Operating systems miscellaneous

  1. Consider a disk queue with requests for I/O to blocks on cylinders 47, 38, 121, 191, 87, 11, 92, 10. The C-LOOK scheduling algorithm is used. The head is initially at cylinder number 63, moving towards larger cylinder numbers on its servicing pass. The cylinders are numbered from 0 to 199. The total head movement (in number of cylinders) incurred while servicing these requests is _______.









  1. View Hint View Answer Discuss in Forum

    The head movement would be :
    63 => 87 24 movements
    87 => 92 5 movements
    92 => 121 29 movements
    121 => 191 70 movements
    191 => 10 0 movement
    10 => 11 1 movement
    11 => 38 27 movements
    38 => 47 9 movements
    Total head movements = 165

    Correct Option: A

    The head movement would be :
    63 => 87 24 movements
    87 => 92 5 movements
    92 => 121 29 movements
    121 => 191 70 movements
    191 => 10 0 movement
    10 => 11 1 movement
    11 => 38 27 movements
    38 => 47 9 movements
    Total head movements = 165


  1. Consider the following code segment :
    x = u – t;
    y = x * v;
    x = y + w;
    y = t – z;
    y = x * y;
    The minimum number of total variables required to convert the above code segment to static single assignment form is __________.









  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    NA



  1. Consider the following statements with respect to userlevel threads and kernel-supported threads:
    1. Context switch is faster with kernel-supported threads
    2. for user-level threads, a system call can block the entire process
    3. Kernel supported threads can be scheduled independently
    4. User level threads are transparent to the kernel Which of the above statements are true?









  1. View Hint View Answer Discuss in Forum

    I) User level thread switching is faster than kernel level switching. SO I is false.
    II) & III) is true.
    IV). User level threads are transparent to the kernel. This is little confusing. If you search define transparent on google, you get definations like "(of a material or article) allowing light to pass through so that objects behind can be distinctly seen." –>" transparent blue water"",
    "easy to perceive or detect." –> "the residents will see through any transparent attempt to buy their votes".
    This makes it all confusing. Though if go & check more definition.
    Computing (of a process or interface) functioning without the user being aware of its presence. So in case of Computing transparent means functioning without being aware. In our case user level threads are functioning without kernel being aware about them. So IV is actually correct. Hence option (a) is correct.

    Correct Option: A

    I) User level thread switching is faster than kernel level switching. SO I is false.
    II) & III) is true.
    IV). User level threads are transparent to the kernel. This is little confusing. If you search define transparent on google, you get definations like "(of a material or article) allowing light to pass through so that objects behind can be distinctly seen." –>" transparent blue water"",
    "easy to perceive or detect." –> "the residents will see through any transparent attempt to buy their votes".
    This makes it all confusing. Though if go & check more definition.
    Computing (of a process or interface) functioning without the user being aware of its presence. So in case of Computing transparent means functioning without being aware. In our case user level threads are functioning without kernel being aware about them. So IV is actually correct. Hence option (a) is correct.


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









  1. View Hint View Answer Discuss in Forum

    In the given program the output is :
    ⚈ 95 is printed by parent : u
    ⚈ 105 is printed by child : x
    u + 10 = x
    The logical addresses remain the same between the parent and child processes. Static Single Assignment is used for intermediate code in compiler design. In Static Single Assignment form(SSA) each assignment to a variable should be specified with distinct names. We use subscripts to distinguish each definition of variables. In the given code segment, there are two assignments of the variable x.
    x = u – t;
    x = y + w;
    and three assignments of the variable y.
    y = x * v;
    y = t – z;
    y = x * y
    So we use two variables x1, x2 for specifying distinct assignments of x and y1, y2 and y3 each assignment of y. So, total number of variables is 10 (x1, x2, y1, y2, y3, t, u, v, w, z).
    Static Single Assignment form(SSA) of the given code segment is:
    x1 = u – t;
    y1 = x1 * v;
    x2 = y1 + w;
    y2 = t – z;
    y3 = x2 * y2;
    Hence answer should be u + 10 = x and v = y

    Correct Option: C

    In the given program the output is :
    ⚈ 95 is printed by parent : u
    ⚈ 105 is printed by child : x
    u + 10 = x
    The logical addresses remain the same between the parent and child processes. Static Single Assignment is used for intermediate code in compiler design. In Static Single Assignment form(SSA) each assignment to a variable should be specified with distinct names. We use subscripts to distinguish each definition of variables. In the given code segment, there are two assignments of the variable x.
    x = u – t;
    x = y + w;
    and three assignments of the variable y.
    y = x * v;
    y = t – z;
    y = x * y
    So we use two variables x1, x2 for specifying distinct assignments of x and y1, y2 and y3 each assignment of y. So, total number of variables is 10 (x1, x2, y1, y2, y3, t, u, v, w, z).
    Static Single Assignment form(SSA) of the given code segment is:
    x1 = u – t;
    y1 = x1 * v;
    x2 = y1 + w;
    y2 = t – z;
    y3 = x2 * y2;
    Hence answer should be u + 10 = x and v = y



  1. A single processor system has three resources types X, Y and Z, which are shared by three processes. There are 5 units of each resources type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process, and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of these processes will finish last?









  1. View Hint View Answer Discuss in Forum

    From the given matrix we found that the number of available resources of X, Y and Z types are 0, 1, 2 respectively. Therefore, P1 will avail these resources first and after release the resources available will be (2, 1, 3) which will be used by P0 as its request is of 1, 0, 3 resources. After P0 releases the resources, the availability becomes (3, 3, 4) and P2 will use these resources then as per its requirements. Thus, P2 finishes in the last.

    Correct Option: C

    From the given matrix we found that the number of available resources of X, Y and Z types are 0, 1, 2 respectively. Therefore, P1 will avail these resources first and after release the resources available will be (2, 1, 3) which will be used by P0 as its request is of 1, 0, 3 resources. After P0 releases the resources, the availability becomes (3, 3, 4) and P2 will use these resources then as per its requirements. Thus, P2 finishes in the last.