Self Studies

Operating System Test 1

Result Self Studies

Operating System Test 1
  • Score

    -

    out of -
  • Rank

    -

    out of -
TIME Taken - -
Self Studies

SHARING IS CARING

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

Self Studies Self Studies
Weekly Quiz Competition
  • Question 1
    2 / -0.33

    The main function of the dispatcher (the portion of the process scheduler) is:

    Solution
    • Mid-term scheduler: swap the processes from the wait state to hard disk
    • Short-term scheduler: selects the processes that are ready to execute and allocates the CPU to one of them
    • Dispatcher: Context switches, in which the dispatcher saves the state of the previous process then the dispatcher loads the saved state of the new process selected by the short-term scheduler
    • Long-term scheduler: bring the processes to main memory from the hard disk
  • Question 2
    2 / -0.33

    Consider the following set of processes {A, B, C, D}, with the arrival time and the CPU burst time given in milliseconds.

    Process Id

    Arrival time

    Burst time

    A

    4

    3

    B

    9

    1

    C

    0

    4

    D

    8

    5

     

    What is the average waiting time in millisecond for these processes with the shortest job first algorithm? 

    Solution

    Gantt chart:

    C

    A

    -

    D

    B

    0             4             7             8              13          14

    Process table:

    Process Id

    Arrival Time (AT)

    Burst Time (BT)

    Completion Time (CT)

    Turn Around Time (TAT)

    Waiting Time (WT)

    A

    4

    3

    7

    3

    0

    B

    9

    1

    14

    5

    4

    C

    0

    4

    4

    4

    0

    D

    8

    5

    13

    5

    0

     

    Average waiting time = \(\frac{0~+4+0+0~}{4}\)

    Average waiting time = 1 ms

    Important Points:

    TAT = CT – AT

    WT = TAT – BT 

  • Question 3
    2 / -0.33
    Suppose there is a paging system with a translation lookaside buffer. Assuming that the entire page table and all the pages are in the physical memory, what is the effective memory access time in ms if it takes 5 msec to search the TLB and 70 msec to access physical memory? The TLB hit ratio is 0.8.
    Solution

    Data:

    TLB hit ratio = p = 0.8

    TLB access time = 5 milliseconds

    Memory access time = m = 70 milliseconds

    Formula:

    EMAT = p × (t + m) + (1 – p) × (t + m + m)

    Calculation:

    EMAT = 0.8 × (5 + 70) + (1 – 0.8) × (5 + 70 + 70)

    EMAT = 89 milliseconds.

    Important points:

    During TLB hit

    The frame number is fetched from the TLB (5 ms)

    and page is fetched from physical memory (70 ms)

    During TLB miss

    TLB no entry matches (5 ms)

    The frame number is fetched from the physical memory (70 ms)

    and pages are fetched from physical memory (70 ms)

  • Question 4
    2 / -0.33
    Consider a computer system having R resources of the same type and these resources are shared by 6 processes that have maximum demands of 7, 5, 3, 8, 4, 6 respectively. Then for what minimum values of R, the system will not be in deadlock?
    Solution

    Concept:

    Deadlock can occur If any process gets < needed (requested) resource

    Max resource per process to be in deadlock = max demand – 1 

    For 6 process, max resource to be in deadlock = (7 – 1) + (5 – 1) + (3 – 1) + (8 - 1) + (4 - 1) + (6 - 1) =27 

    For 6 process, min resource not to be in a deadlock: 27 + 1 =28

    Tips and Tricks:

    \(\sum_i^nP_i\ -\ n +1 =(7+5+3+8+4+6)-6 + 1=28\)

    where Pi is the max resource needed by the ith process and n is the total number of process

  • Question 5
    2 / -0.33

    Which of the following is TRUE about user-level threads and kernel-level threads?

    S1: Typically if a user-level thread is performing blocking system call then the entire process will be blocked

    S2: Kernel level threads are designed as dependent threads

    S3: Every thread has its own register and stack
    Solution

    S1: TRUE:

    If a user-level thread block then entire process will get blocked

    S2: FALSE

    Kernel level threads are independent that is why they also require more context switch than user – level threads.

    S3: TRUE

    Every thread has its own register and stack

    Therefore S1 and S3 are TRUE

  • Question 6
    2 / -0.33
    Consider a hypothetical system with byte-addressable memory, 64-bit logical addresses, 8 Megabyte page size and page table entries of 16 bytes each. What is the size of the page table in the system in terabytes?
    Solution

    Data

    1 word (W) = 1 byte (B)

    Logical address = 264 B

    page size = 8 MB = 223 B

    page table entry (PTE) = 16 B

    Formula:

    Page table size (PTS) = number of pages × PTE

    Calculation:

    number of pages = \(\frac{{{2^{64}}}}{{{2^{23}}}} = {2^{41}}\)

    Page table size (PTS) = number of pages × y

    \(PTS = {2^{41}} \times 16\;B = 2^{45} \;B\)

    ∴ PTS = 32 TB

    Important points

    1 TB = 240 B

    where B stands for byte

  • Question 7
    2 / -0.33

    Suppose that jobs arrive according to the following schedule :                                                 

    Process Arrival time    Run time
    A12
    37
    62
    D85
    E92
    F1212

       

    Now give the sequence of the processes as they gets share of CPU if the scheduler used is Shortest Remaining Time First.

    Solution

    Concept:

    Shortest remaining time next:  pre-emptive scheduling

    In shortest remaining time next, when a process of less burst time(run time) arrives than in ready queue then context switch will happen

    Explanation:

    Time           Running                  Remaining times at the end

    0 – 3             A                                 A – 9  B – 7

    3 – 6             B                                 A – 9  B – 4  C – 2

    6 – 8             C                                 A – 9  B – 4  D – 5

    8 – 9             B                                 A – 9  B – 3  D – 5  E – 2

    9 – 11            E                                 A – 9  B – 3  D – 5

    11 – 12          B                                 A – 9  B – 2  D – 5  F – 12

    12 – 14          B                                 A – 9  D – 5  F – 12

    14 – 19          D                                 A – 9  F – 12

    19 – 28          A                                 F – 12

    28 – 40          F
  • Question 8
    2 / -0.33

    The process executes the code where x is an integer and x is initialized to 10

    while(--x){

    fork();

    if(x == 2)

    break;

    }

    The total number of child processes created is
    Solution

     Value of x first decremented(--x) 

    while condition

    fork calling

    9

    True

    called

    8

    True

    called

    7

    True

    called

    6

    True

    called

    5

    True

    called

    4

    True

    called

    3

    True

    called

    2

    True

    called (but break the while loop)

     

    From the table it is clear that fork is called 8 times

    Formula:

    If n times fork is called the number of child processes created = 2n – 1

    Calculation:

    Since n = 8

    number of child processes created = 28 - 1 = 255

  • Question 9
    2 / -0.33
    A system has 12 identical resources and Y processes competing for them. Each process can request at most 3 resources. Which one of the following values of Y could lead to a deadlock?
    Solution

    Data:

    Available identical Resources = R = 12

    Max needs per process = 3

    Concepts:

    Deadlock can occur If any process gets available resource < needed (requested) resource

    Max resource per process to be in deadlock = needed – 1 = 3 – 1 = 2

    For Y process, max resource to be in deadlock = Y × 2 = 2Y

    Condition for deadlock

    2Y ≥ R

    2Y ≥ 12

    Y  ≥ 6

    values of Y could lead to a deadlock is 6 and 7

  • Question 10
    2 / -0.33
    At time 0, an OS with round-robin scheduling (time quantum = 5 units) has 5 processes P1, P2, P3, P4, P5 with burst times 15, 10, 20, 5, 15 respectively. What is the average turn-around time?
    Solution

    Concept:

    The round-robin (RR) scheduling algorithm is designed especially for timesharing systems.

    It is similar to FCFS scheduling, but preemption is added to enable the system to switch between processes.

    A small unit of time, called a time quantum or time slice, is defined.

    The ready queue is treated as a circular queue. The CPU scheduler goes around the ready queue, allocating the CPU to each process for a time interval of up to 1-time​ quantum.

    Time quantum = 5 units

    Gantt Chart:

    P1

    P2

    P3

    P4

    P5

    P1

    P2

    P3

    P5

    P1

    P3

    P5

    P3

    0       5        10     15       20      25      30      35     40       45      50      55      60      65

    Calculation

    Process

    Arrival Time (AT)

    Burst Time (BT)

    Completion Time (CT)

    Turnaround time =

    CT – AT

    P1

    0

    15

    50

    50

    P2

    0

    10

    35

    35

    P3

    0

    20

    65

    65

    P4

    0

    5

    20

    20

    P5

    0

    15

    45

    45

     

    Average turn around time = \(\frac{20 + 35 + 50 + 60 + 65}{5} = 46\)

  • Question 11
    2 / -0.33

    Which of the following is/are not true about the deadlock scheme?

    I.  In deadlock avoidance, number the resource uniquely and never requests a lower-numbered resource

    II. In deadlock avoidance, the request for the resources is always granted if the resulting state is safe.

    III. In deadlock prevention, never request a resource after releasing any resource.

    Solution

    Statement I: not true (False)

    In deadlock prevention, number the resource uniquely and never requests a lower-numbered resource

    Statement II:  True

    In deadlock avoidance, the request for the resources is always granted if the resulting state is safe.

    Statement IIi: not true (False)

    In deadlock prevention, the request can be made after releasing the resource

    Statement I and III are not true

  • Question 12
    2 / -0.33
    Consider a counting semaphore S. The operation P(S) performs the operation S = S – 1 and operation V(S) performs the operation V = V + 1. During program execution, 13P and 5V operation is performed in the some order. Find the number of processes in a blocked state with initial counting semaphore value 1.
    Solution

    Concepts:

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

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

    Data:

    Initial counting semaphore = x = 1

    Signal operation = 11 V

    Wait operation = 17 P

    n process in blocked state

    Final counting semaphore (F) = -n

    Formula:

    n = x + 13P + 5V

    Calculation:

    n = 1 + 13(-1) + 5(+1)

    ∴ n = -7

    ∴ number of process in blocked state is 7
  • Question 13
    2 / -0.33
    A computer uses 48 bits Virtual Address Space, 256 GB of physical memory with page size of 4 KB. The page table size is 4 bytes and if each entry fits in a single page the number of levels of paging required is _____.
    Solution

    Data:

    Virtual address space (VAS) = 48 bits

    Virtual memory (VA) = 248 Byte

    Physical Memory (PA) = 256 GB

    Page size (PS) = 4 KB = 212 B

    Page Table size (PTS) = 4 bytes

    Formula:

    \({\rm{page\;table\;size\;}} = \frac{{{\rm{VA}}}}{{{\rm{PS}}}} \times {\rm{PTS\;}}\)

    Calculation:

    \({\rm{Level\;}}1:{\rm{\;page\;table\;size\;}} = \frac{{{2^{48}}}}{{{2^{12}}}} \times 4\;{\rm{byte}} = {2^{38}}\;{\rm{byte}} > {\rm{PTS}}\)

    \({\rm{Level\;}}2:{\rm{page\;table\;size\;}} = \frac{{{2^{38}}}}{{{2^{12}}}} \times 4\;{\rm{byte}} = {2^{28}}\;{\rm{byte}} > {\rm{PTS}}\)

    \({\rm{Level\;}}3:{\rm{page\;table\;size\;}} = \frac{{{2^{28}}}}{{{2^{12}}}} \times 4\;{\rm{byte}} = {2^{18}}\;{\rm{byte}} > {\rm{PTS}}\)

    \({\rm{Level\;}}4:{\rm{page\;table\;size\;}} = \frac{{{2^{18}}}}{{{2^{12}}}} \times 4\;{\rm{byte}} = {2^8}\;{\rm{byte}} \le {\rm{PTS}}\)

    The number of levels of paging required is 4.

    Important Points:

    If page table size (PTS) is less than or equal to page size, then page table can be stored in that level.
  • Question 14
    2 / -0.33

    Consider two processes P1 and P2 executing their respective codes initial values of global variables P1_inside and P2_inside are “false”.

    P1

    P2

    while(true)

    {

    while(P1_inside);

    P1 inside=true;

    C.S.                  // critical section

    P1 inside =false;

    }

    while(true)

    {

    while(P2_inside);

    P2 inside=true;

    C.S.                    // critical section

    P2 inside=false;

    }

     

    Consider the below statements:

    1. Mutual exclusion is satisfied
    2. Mutual Exclusion is not satisfied
    3. It is possible for deadlock

    Which of the above are true?

    Solution
    P1 executes while and P2 executes while. Then by executing assignment statement, both P1 and P2 can enter the critical section.  So mutual exclusion is not satisfied.
  • Question 15
    2 / -0.33

     

    Allocation

    Max

    Available

     

    A     B      C     D

    A     B      C    D

    A     B      C       D

    P0

      0     0      1        2

    0     0      1        2

    1     5      2        0

    P1

    1     0       0       0

    1     7      5        0

     

    P2

    1     3      5        4

      2     3      5        6  

     

    P3

    0     6      3         2

    0     6      5        2

     

    P4

    0     0       1          4

    0     6      5        6

     

    Which of the following is true for the above-given resource allocation table?

    Solution

    Concepts:

    If all processes able to terminate from a state than the state is safe. 

    In other words, if we can find a safe sequence (order of termination of the process) then the process is in a safe state.

    Resources needed:

     

    Need

     

    A       B         C         D

    P0

    0        0          0         0

    P1

    0        7          5         0

    P2

    1        0          0         2

    P3

    0        0          2         0

    P4

    0        6         4          2

     Available <1, 5, 2, 0>

    Sequence of safe state:

    Since P0 doesn't needed any instance of resource, it will release it allocated resources

    ∴ Available =  <1, 5, 2, 0> + <0, 0, 1, 2> = <1, 5, 3, 2>

    P3 needs <0, 0, 2, 0>, is less than avaible, after P3 execution

    ∴ Available =  <1, 5, 3, 2> + <0, 6, 3, 2> = <1, 11, 6, 4>

    P2 needs <1, 0, 0, 2>, is less than avaible, after P2 execution

    ∴ Available =  <1, 11, 6, 4> + <1, 3, 5, 4> = <2, 14, 11, 8>

    P4 needs <0, 6, 4, 2>, is less than avaible, after P4 execution

    ∴ Available = <2, 14, 11, 8> + <0, 0, 1, 4> = <2, 14, 12, 12>

    P1 needs <0, 7, 5, 0>, is less than avaible, after P1 execution

    ∴ Available = <2, 14, 12, 12> + <1, 0, 0, 0> = <3, 14, 12, 12>

    Process are able to finish in this situation so system is in safe state, and one of the safe sequence is <P0, P3, P2, P4, P1>

  • Question 16
    2 / -0.33
    Consider a file system that uses inodes to represent files. Disk blocks are 12 KB in size, and a pointer to a disk block requires 8 bytes. This file system has 10 direct disk blocks, as well as single and double indirect disk blocks. What is the maximum size in GB (up to two decimals) of a file that can be stored in this file system?
    Solution

    Data:

    In index node of a Unix- style file system,

    Direct Block pointer = 10

    Single Indirect Block pointer = 1

    Double Indirect Block pointer = 1

    Disk block address = disk block entries size = 8 B

    Disk Block size = 12 KB

    Calculation:

    Number of entries in a block = \(\frac{disk\; block\; size}{disk\; block\; address\; size} = \frac{12\;K B}{8\;B} \) = 3 × 29

    File size = (10 direct + 1 singel indirect + 1 double indirect) × 12 KB

    File size = (10 × 1 + 1 × 3 × 29 + 1 × 3 × 29  × 3 × 29 )× 12 KB

    File size = (15 × 213  + 9 × 221 B + 27 × 230)

    File size = 0.00011 GB + 0.017578 GB + 27 GB

    ∴ file size ≈ 27.02

  • Question 17
    2 / -0.33
    Consider a n-way set associative cache memory with 8 sets and 16 cache blocks (0-15) and a main memory with 512 blocks (0 - 511). What memory blocks will be present in the cache after the sequence 17, 4, 13, 105, 28, 29, 200, 408, 127, 205, 411, 251 if LRU is used as a cache replacement block?
    Solution

    Data:

    number of sets = 8

    cache blocks = 16

    Formula:
    memory block placed in cache = memory block%8

    Calculation:

    set associative = \(\frac{{16}}{8} = 2\) 

    ∴ in one set two memory block can be placed

    0

    200

    408

    1

    17

    105

    2

     

     

    3

    411

    251

    4

    4

    28

    5

    13 (Replace 13) with 205

    29

    6

     

     

    7

    127

     

     

    4, 13, 105, 28, 29, 200, 408, 127, 205, 411, 251 is the correct answer:

    Important Points:

    LRU is used and hence 13 is replaced with 205

  • Question 18
    2 / -0.33

    Three CPU-bound tasks, with execution times of 15, 12 and 5 time units respectively arrive at times 0, t and 8, respectively. If the operating system implements a shortest remaining time first scheduling algorithm, what should be the value of t to have 4 context switches?

    Ignore the context switches at time 0 and at the end.
    Solution

    Process scheduling Algorithm: shortest remaining time first scheduling

    Process Table:

    Process

    Arrival Time

    Burst Time

    P0

    0

    15

    P1

    t

    12

    P2

    8

    5

     

    Gantt Chart:

    At t = 0:

    P1

    P1

    P2

    P0

    0           8            12          17          32

                               1st              2nd 

    2 context switches occur. Hence Option 2  and 3 is eliminated.

    At t = 1:

    P0

    P1

    P2

    P1

    P0

    0           1            8           13           18         32

                  1st        2nd         3rd          4th   

    4 context switches occur.

    Since P2 and P1 has the same burst time we can choose any process at t = 8

    At t = 2:

    P0

    P1

    P2

    P1

    P0

    0           2            8           13           19          32

                 1st         2nd         3rd          4th  

    4 context switches occur.

    At = 5:

    P0

    P0

    P2

    P0

    P1

    0           5            8           13           20          32

                               1st         2nd          3rd  

    Only 3 context switches occur. Hence Option 4 is also eliminated.

    Therefore, option 1 is the correct answer
Self Studies
User
Question Analysis
  • Correct -

  • Wrong -

  • Skipped -

My Perfomance
  • Score

    -

    out of -
  • Rank

    -

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