Self Studies

Operating System Test 2

Result Self Studies

Operating System Test 2
  • 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 process executes the code where i is an integer:

    for(i = 0; i <=15; i++)

    {

    if(i == 5)

    continue;

    fork();

    if(i == 10)

    break;

    }

    The total number of new processes created is _____.
    Solution

     Value of i

    Condition

    fork calling

    0

    Continue and break both not executed

    Called

    1

    Continue and break both not executed

    Called

    2

    Continue and break both not executed

    Called

    3

    Continue and break both not executed

    Called

    4

    Continue and break both not executed

    Called

    5

    Continue executed

    not called

    6

    Continue and break both not executed

    Called

    7

    Continue and break both not executed

    Called

    8

    Continue and break both not executed

    Called

    9

    Continue and break both not executed

    Called

    10

    Break executes

    (loop terminate)

    Called (fork is executed before break)

    11 to 15

    Not executed

     

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

    Formula:

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

    Calculation:

    Since n = 10

    number of child processes (new processes) created = 210 - 1 = 1023 

  • Question 2
    2 / -0.33
    Consider a system has hit ratio as h%. Average access time to service a page fault is s milliseconds and average effective memory access time is e in milliseconds. What is the memory access time in microseconds (m is considered with service time)?
    Solution

    Service time = s milliseconds = 1000s microseconds

    Hit ratio = h % = h ÷ 100

    ∴ miss ratio = p = (1 - h ÷ 100) (page fault rate)

    EMAT = e millisecond = 1000e microseconds

    If m is considered

    EMAT = p × (s + m) + (1 - p) × m

    EMAT = p × s + m

    Substitute the values:

    1000e = (1 – (h ÷ 100)) 1000s + m

    ∴ m = 1000 × e - 1000 × s + 10 × s × h

    ∴ m = 10 × (100 × (e - s) + s × h)

    Important Points:
    EMAT → effective memory access time

    p → page fault rate

    s → service time

    m → memory access time

    Confusion point:

    m is very large, in this case m is ignored and not take with service time

    EMAT = p × s + (1 - p) × m

    If m is considered

    EMAT = p × (s + m) + (1 - p) × m

    EMAT = p × s + m

  • Question 3
    2 / -0.33

    Which of the following statements are true?

    (a) External Fragmentation exists when there is enough total memory space to satisfy a

    request but the available space is contiguous.

    (b) Memory Fragmentation can be internal as well as external.

    (c) One solution to external Fragmentation is compaction.
    Solution

    (a) External Fragmentation exists when there is enough total memory space to satisfy a

    request but the available space is contiguous.

    This statement is incorrect. As process are loaded and removed from memory, the free memory space is  broken into little pieces. External fragmentation exists when enough total memory space exists to satisfy a request but it is not contiguous; storage is fragmented into large number of small holes.  External fragmentation is also known as checker boarding. Suppose we have memory blocks available of size 400KB each. But if request come for 600Kb then it cannot be allocated.

    (b) Memory Fragmentation can be internal as well as external.

    This statement is correct. There is an important issue related to the contiguous multiple partition allocation scheme is to deal with memory fragmentation. There are two types of fragmentation: internal and external fragmentation. Internal fragmentation exists in the case of memory having multiple fixed partitions when the memory is allocated to a process is not fully used by the process.

    c) One solution to external Fragmentation is compaction.

    Given statement is correct. To get rid of external fragmentation problem, it is desirable to relocated some or all portions of the memory in order to place all the free holes together at one end of memory to make one large hole. This technique of reforming the storage is known as compaction.
  • Question 4
    2 / -0.33

    Which of the following statement is not true about round – robin scheduling?

    Solution

    Concept:

    The round – robin scheduling algorithm is designed for time sharing systems. It is similar to FCFS but preemption is added to enable the system to switch between processes.

    Explanation:

    Some points about round- robin scheduling :

    • To implement round robin, we keep the queue as a FIFO queue of processes.
    • Round robin scheduling is preemptive.
    • If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units. Each process must wait no longer than (n-1) × q time units until its next time quantum.
    • Performance of the round robin algorithm depends on the size of time quantum.
    • If time quantum is too large, then round robin behaves like FCFS.
    • If time quantum is too small, then this approach is called processor sharing.
  • Question 5
    2 / -0.33
    Which of the following statement is correct about cascading termination of a child process?
    Solution

    Concept:

    Fork system call is used to create a new process. Newly creates process is known as child process. Fork system call takes no arguments and return a process ID.

    Explanation:

    A process terminates when it finishes its final statement and asks the operating system to delete it by using the exit() system call. At that point, process may return a status value to its parent process. All the resources are deallocated by the operating system.

    A parent may terminate the execution of one of its children for a variety of reasons such as :

    • Child has exceeded its usage of some of the resources that it has been allocated
    • The task assigned to the child is no longer required.
    • The parent has terminated and operating system does not allow a child to exist. This is known as cascading termination.
  • Question 6
    2 / -0.33
    Given the Burst Time (BT) of 4 processes P1, P2, P3, and P4 as BT(t1, t2, t3, t4) – (4, 8, 6, 7), smoothening factor(α) – 0.5, and T1 = 10, what will be the burst time of process P5 for shortest Job first scheduling, using the technique of exponential averaging?
    Solution

    In case of exponential averaging, formula used is:

    T’ = αt1 + (1 - α)T

    Here processes are given as:

    Processes

    Burst time(t)

    P1

    4

    P2

    8

    P3

    6

    P4

    7


    Here α = 0.5, T1 = 10

    T2 = 0.5 × 4 + (1 – 0.5) × 10

    = 2 + 5 = 7

    T3 = 0.5 × 8 + 0.5 × 7

    = 4 + 3.5 = 7.5

    T4 = 0.5 × 6 + 0.5 × 7.5

    = 3 + 3. 75 = 6.75

    T5 = 0.5 × 7 + 0.5 × 6.75

    = 3.5 + 3.375 = 6.875

    Required burst time = 6.875 time units
  • Question 7
    2 / -0.33
    The probability that a process spends its time in performing I/O operations is 50%. In a multi programmed operating system environment, if there are 4 processes in memory at once, then the probability that all processes are waiting for I/O and the system utilization are respectively
    Solution

    Concept:

    If the probability of process spending its time in performing I/O operations is P.

    Then probability that all processes goes for I/O is P*P*P……….*P for n processes i.e. Pn.

    Hence, the probability of CPU utilization will be 1- pn.

    Explanation:

    Here, the probability that a process spends its time in performing I/O operations is 50% i.e. 0.5

    Then probability that all processes are waiting for I/O = (0.5)4

    The probability of CPU utilization = 1 – (0.5)n

  • Question 8
    2 / -0.33

    Mutual exclusion problem occurs

    Solution

    Concept:

    Mutual exclusion happens when two or more processes share the same resources but can not access the same resource at the same time. 

    Explanation:

    Mutual exclusion is a property of concurrency control, which is instituted for the purpose of preventing race conditions.

    It is the requirement that one thread of execution never enters its critical section at the same time that another concurrent thread of execution enters its own critical section. This problem is resolved using different tools, e.g. semaphores.

  • Question 9
    2 / -0.33
    Consider a system having 20 resources of same type. These resources are shared by 4 process which have peak demands of 4, 5, x, y respectively. What is the maximum value of x + y to ensure that there will be no deadlock in the system?
    Solution

    Concept:

    Deadlock is a situation that happens when two or more process requests for a resource which is held by another process.

    Explanation:

    Given:

    20 resources of same type.

    Four processes with demand of 4, 5, x, y respectively.

    So, (4 - 1) + (5 - 1) + (x -1) + (y -1) + 1 = 20

    3 + 4 + x – 1 + y – 1 + 1 = 20

    7 + x – 1 + y = 20

    x + y + 7 = 21

    x + y = 14

    Maximum value of x + y so that there will be no deadlock in system = 14.
  • Question 10
    2 / -0.33

    Consider the following scenario: A, B, C, D are processes and X, Y are resources used by the processes.

    Process has-X has-Y max-needs-X max-needs-Y
    A 35 10 65 40
    B 55 80 105 220
    C 35 20 110 50
    D 0 70 50 90

    If Resources available: [X: 40 Y: 40] then what will be a safe sequence so that the processes complete execution without deadlock?

    Solution

    Data:

    Remaining Need(X) = (max-needs-X) – (has-X)

    Remaining Need(Y) = (max-needs-Y) – (has-Y)

    Process

    Remaining Need (X)

    Remaining Need (Y)

    A

    30

    30

    B

    50

    140

    C

    75

    30

    D

    50

    20

     

    Calculation:

    Available resource of X = 40

    Available resource of Y = 40

    Sequence: ACDB

    Need of A(30, 30) ≤ available of (40, 40)

    A is executed and release the resource held by it

    Available of X = 40 + 35 = 75

    Available of Y = 40 + 10 = 55

    Available of (X, Y) = (75, 55)

    Need of C(75, 30) ≤ available of (75, 55)

    Also Need of D(X, Y) ≤ available of (X, Y)

    Taking C first (as an exercise take D and solve)

    C is executed and release the resource held by it

    Available of X = 75 + 35 = 110

    Available of Y = 55 + 20 = 75

    Available of (X, Y) = (110, 75)

    Need of D(50, 20) ≤ available of (110, 75)   // B won't be satisfied

    D is executed and release the resource held by it

    Available of X = 110 + 0 = 110

    Available of Y = 75 + 70 = 145

    Available of (X, Y) = (110, 140)

    Need of B(50, 140) ≤ available of (110, 140)

    B is executed and release the resource held by it

    Available of X = 110 + 50 = 160

    Available of Y = 145 + 140 = 285

    Available of (X, Y) = (160, 2885)

    ∴ safe sequence is ACDB

    Similarly, safe sequence is ADCB

  • Question 11
    2 / -0.33
    Consider a shared variable with initial value 10, this shared variable is used by four concurrent processes A, B, C and D. Process A reads the shared variable and decrements it by two and process B reads the shared variable and increment it by three before writing it to the memory. Process C reads the shared variable and decrement it by three while process D reads the shared variable and increment it by two before writing it to the memory. All the process before reading the value performs the wait operation on a counting semaphore variable S and after writing it to the memory, a signal operation is performed before the processes get terminated. Find the minimum possible value of the shared variable in the memory if S is 2?
    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:

    Shared variable = x = 10

    Counting semaphore = S = 2

    Process A:

    Process B:

    Process C:

    Process D:

    P(S)

    P(S)

    P(S)

    P(S)

    r(x)

    r(x)

    r(x)

    r(x)

    x = x - 2

    x = x + 3

    x = x - 3

    x = x + 2

    w(x)

    w(x)

    w(x)

    w(x)

    V(S)

    V(S)

    V(S)

    V(S)

    exit(A)

    exit(B)

    exit(C)

    exit(D)

     

    Calculation:

    If Process A is executed completely

    x = 10 – 2 = 8

    and S = 2

    Process C reads the value and decrement it by 3

    x = 8 – 3 = 5

    S = 1

    Note that still process C doesn’t write it to memory

    If Process B is executed completely

    x = 8 + 3 = 11

    S = 1

    If Process D is executed completely

    x = 11 + 2 = 13

    S = 1

    Now, C writes the value x = 5

    ∴ minimum possible value is 5.
  • Question 12
    2 / -0.33
    Consider six memory partitions of size 250KB, 470KB, 600 KB, 500 KB, 300KB, and 410 KB where KB refers to kilobyte. These partitions need to be allotted to four processes of sizes 350 KB, 200 KB , 468 KB and 480 KB in that order. Which partitions are not allotted to any process when we use best fit and worst fit algorithm?
    Solution

    Concept:

    Best fit algorithm: In this method, algorithm searches the complete list of partitions and then chooses the smallest hole in which process can fit with minimum internal fragmentation.

    Worst fit algorithm: In this method, algorithm searches the complete list of partitions and then chooses the largest hole in which process can fit with maximum internal fragmentation.

    Explanation:

    Given partitions are:

    250KB, 470KB, 600 KB, 500 KB, 300KB, and 410 KB

    Processes are: 350 KB, 200 KB, 468 KB and 480 KB

    Using best fit policy:

    200KB

    468KB

     

    480KB

     

    350KB

    250KB         470KB       600KB        500KB     300        410

    Using worst fit policy:

     

    468KB

    350KB

    200KB

     

     

    250KB          470KB       600KB        500KB     300        410

    Using worst fit, one process cannot be allocated any partition. 

  • Question 13
    2 / -0.33

    A demand - paging uses a TLB (Translation Look - aside Buffer) and single level page table stored in main memory. The memory access time is 5 μs and the page fault service time is 25 ms. If 70% of access is in TLB with no page fault and of the remaining, 20% is not present in main memory. The effective memory access time in ms is _________. (Write answer up to two decimal places)

    Solution

    EAT = ht (tt + tm) + (1 – ht) [p * (tt + (n + 1) tm) + (1 – p) = td]

    = 0.7 * (0 + 5 μs) + 0.3 * [0.8(0 + 2 * 5 μs) + 0.2 * 25 ms]

    = 3.5 μs + 0.3 * [8 μs + 5000 μs]

    = 1505.9 μs = 1.5 ms

  • Question 14
    2 / -0.33

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

    Solution

    Option 1: TRUE:

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

    Option 2: FALSE

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

    Option 3: TRUE

    Every thread has its own register and stack

    Option 4: TRUE

    Communication between multiple threads is easier, as the threads shares common address space. while in process we have to follow some specific communication technique for communication between two process.

  • Question 15
    2 / -0.33

    A system uses FIFO policy for page replacement. It has 4 page frames with no pages loaded to begin with. The system first accesses 50 distinct pages in some order and then accesses the same 50 pages in reverse order. How many page faults will occur?

    Solution

    Concept:

    In the First In First Out (FIFO) algorithm, the operating system keeps track of all pages in the memory in a queue, the oldest page is in the front of the queue. When a page needs to be replaced page in the front of the queue is selected for removal.

    Explanation:

    Page frames = 4

    Pages: 1, 2, 3, 4 .... 45, 46, 47, 48, 49, 50, 50(H), 49(H), 48(H), 47(H), 46, 45, .....4, 3, 2, 1

    First 50-page accesses will cause page fault but in reverse order page number 50, 49, 48, and 47 will not cause a page fault.

    Hence total page faults are 50 + 46.

    Notes:

    H→ Hit

  • Question 16
    2 / -0.33

    Consider the three processes P1, P2 and P3 shown below with their arrival time and burst time.

    Which of the following statement is correct for this process table.

    Processes

    Arrival time

    Burst time

    P1

    0

    5

    P2

    1

    7

    P3

    2

    4

     

    NOTE:

    Time Quantum 2 units for Round robin

    Solution

    Process table for FCFS :

    Processes

    Arrival time(AT)

    Burst time(BT)

    Completion time(CT)

    Turn around time(TAT)= CT - AT

    P1

    0

    5

    5

    5

    P2

    1

    7

    12

    11

    P3

    2

    4

    16

    14

     

    Gantt chart for FCFS:

    0         5          12         16          

    P1

    P2

    P3

     

    Average turn around time = (5 + 11 + 14)/3 = 10

    Process table for SRTF:

    Processes

    Arrival time(AT)

    Burst time(BT)

    Completion time(CT)

    Turn around time(TAT)= CT - AT

    P1

    0

    5

    5

    5

    P2

    1

    7

    16

    15

    P3

    2

    4

    9

    7

     

    Gantt chart for SRTF:

    0           5            9           16            

    P1

    P3

    P2

     

    Average turn around time = (5 + 15 + 7)/ 3 = 9

    Process table for SJF:

    Gantt chart for SJF:

    0         5         9        16            

    P1

    P3

    P2

     

    In this case, SJF Gantt chart is same as SRTF. So, average turn around time will be same as SRTF i.e. 9 time units.

    Process table for Round- robin:

    Processes

    Arrival time(AT)

    Burst time(BT)

    Completion time(CT)

    Turn around time(TAT)= CT - AT

    P1

    0

    5

    13

    13

    P2

    1

    7

    16

    15

    P3

    2

    4

    12

    10

     

    Gantt chart for RR with time quantum = 2 units

    0          2           4          6           8         10          12        13        16

    P1

    P2

    P3

    P1

    P2

    P3

    P1

    P2

     

    Average turn around time = (13 + 15 + 10)/ 3 = 12.6 units

  • Question 17
    2 / -0.33
    Consider a Unix node which maintains 16 direct blocks pointer, 2 single indirect, 4 double indirect and 8 triple indirect block pointers. Disk block size if 8 KB and disk address is 32 bits. The maximum possible size of file is ____ TB (up to 1 decimal places).
    Solution

    Data:

    Direct Block = 16

    Single Indirect Block = 2

    Double Indirect Block = 4

    Triple Indirect Block = 8

    Disk Block size = 8 KB

    Disk address = disk block entries size = 32 bit = 4 bytes

    Calculation:

    Number of entries in a block = 8kB4B=211

    File size = (16 direct + 2 single indirect block + 4 double indirect + 8 triple indirect) × block size

    File size = (16 × 1 + 2 × 211 + 4 × 211 × 211 + 8 × 211 × 211 × 211) × 8 KB

    File size = 128 KB + 32 MB + 128 GB + 512 TB

    File size = 512.12503 TB
  • Question 18
    2 / -0.33

    The address sequence generated by tracing a particular program executing in a pure demand paging system with 100 records per page, with 1 free main memory frame is recorded as follows. What is the number of Page Faults?

    0100, 0200, 0430, 0499, 0510, 0530, 0560, 0120, 0220, 0240, 0260, 0320, 0370
    Solution

    Concept:

    Page fault means when a program attempts to access a block of memory that is not stored in the physical memory.

    Data:

    Page size = 100 records

    Frame size = 100 records

    Explanation:

    1st request 0100 record

    Main Memory (MM) :  Empty

    Page fault

    2nd request 0200 record

    MM after 1st request: [ 100 to 199 ]

    Page fault

    3rd request 0430 record

    MM after 2nd request: [ 200 to 299 ]

    Page fault

    4th request 0499 record

    MM after 3rdrequest:  [400 to 499 ]

    Page Hit

    5th request 0510 record

    MM after 4th request:  [ 400 to 499 ]

    Page fault

    6th request 0530 record

    MM after 5th request:  [ 500 to 599 ]

    Page Hit

    7th request 0560 record

    MM after 6th request:  [ 500 to 599 ]

    Page Hit

    8th request 0120 record

    MM after 7th request :  [ 500 to 599 ]

    Page fault

    9th request 0220 record

    MM after 8th request:  [ 100 to 199 ]

    Page fault

    10th request 0240 record

    MM after 9th request:   [ 200 to 299 ]

    Page Hit

    11th request 0260 record

    MM after 10th request: [ 200 to 299 ]

    Page Hit

    12th request 0320 record

    MM after 11th request: [ 200 to 299 ]

    Page fault

    13th request 0370 record

    MM after 12th request: [ 300 to 399 ]

    Page Hit

     

    MM after 13th request: [ 300 to 399]

     


    Total number of page fault is 7.

  • Question 19
    2 / -0.33

    A system has n resources R0,...., R 12, and k processes P0,...Pk-1.The implementation of the resource request logic of each process Pis as follows:

    if (i%2 == 0)

    {

    if (i < n) request Ri

    if (i+2 < n) request Ri+2

    }

    else

    {

    if(i < n) request Rn - i

    if (i+2 < n) request Rn-i-2

    }

    Maximum number of the process so deadlock is possible ______

    Solution

    Concept:

    Direct formula:

    n should be odd then deadlock will be possible if k should be = n+22 

    Calculation:

    n = 13 then k will be 13+22=152=8

    Hence n = 13 and k = 8 then deadlock is possible. 

  • Question 20
    2 / -0.33
    In a certain computer, the virtual addresses are 32 bits long and the physical addresses are 48 bits long. The memory is word addressable. The page size is 16 kB and the word size is 2 bytes. The Translation Look-aside Buffer (TLB) in the address translation path has 64 valid entries. Hit ratio of TLB is 100% then maximum number of distinct virtual addresses that can be translated is _____ K.
    Solution

    Data:

    Memory is word addressable.

    1 word = 2 bytes

    Virtual Address (VA) = 32 bits

    ∴ Virtual Address Space (VAS)= 232 words

    Physical Address (PA) = 48 bits

    ∴ Physical Address Space (PAS) = 248 words

    Page size (PS) = 16 KB = 213 words = Frame size

    Translation Look a side Buffer (TLB)

    Page number

    Frame number

    Page size = Frame size

    Calculation:

    For single TLB hit,

    ∵ Frame size = 213 words

    Virtual address translated is 213

    Hit ration is 100%

    For 64 TLB hit,

    Maximum virtual address translated = 64 × 213 = 219 = 512 K

    Tips and Tricks:

    K = 210

    Maximum distinct virtual addresses can be translated without any TLB miss = TLB entries × Page size
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