程序代写代做代考 data structure Feedback on Quiz # 4 (Summative)

Feedback on Quiz # 4 (Summative)
The Quiz # 4 was composed of 10 questions, which were randomly selected from a Question Bank of 20 questions. Answers and feedback comments for all of the questions are given below:
Q01
A long-term scheduler controls the degree of multiprogramming in an Operating System. The long-term scheduler can send a process to which one(s) of the following states?
(Select all that apply. Marks will be deducted for incorrect answers)
(a)
Ready state
(b)
Blocked state
(c)
Ready, Suspend state
(d)
Running state
(e)
Blocked, Suspend state
Feedback:
The Long-term scheduler selects which processes should be admitted into the system and be placed in either the ready state or the ready-suspend state. The other states i.e. Blocked, Running and Blocked,Suspend states are not ‘managed’ by the long-term scheduler.
Q02
(a)
(b)
(c)
(d)
(e)
A long-term scheduler controls the degree of multiprogramming in an Operating System. The long-term scheduler cannot send processes to which one(s) of the following states?
(Select all that apply. Marks will be deducted for incorrect answers)
Ready state
Blocked state
Ready, Suspend state
Running state
Blocked, Suspend state
Feedback:
The Long-term scheduler selects which processes should be admitted into the system and be placed in either the ready state or the ready-suspend state. It cannot send processes to the blocked, running or block,suspend states.

Q03
Consider that you have written a program that allocates a large amount of memory for building a dynamic array containing students’ data. Where will this array be placed in the process’ memory image?
(Select all that apply. Marks will be deducted for incorrect answers)
(a)
Program Segment
(b)
Heap Segment
(c)
Stack Segment
(d)
Text Segment
(e)
Kernel Segment
Feedback:
All the dynamically allocated data structures such as arrays are placed in the Heap Segment. Program segment and the Text segment are the same thing and contain the program instructions that are executed by the process. Stack segment contains all data / variables that are related to function calls like parameters and local variables. Kernel segment is not really a segment in the process memory layout.
Q04
Consider that you have written a program that allocates a large amount of memory (at compile time) for holding an array containing students’ data. Where will this array be placed in the process’ memory image?
(Select all that apply. Marks will be deducted for incorrect answers)
(a)
Data Segment
(b)
Program Segment
(c)
Stack Segment
(d)
Text Segment
(e)
Kernel Segment
Feedback:
The compile time variables / data structures such as arrays are placed in the Data Segment. Program segment and the Text segment are the same thing and contain the program instructions that are executed by the process. Stack segment contains all data / variables that are related to function calls like parameters and local variables. Kernel segment is not really a segment in the process memory layout.

Q05
Suppose we are moving down the storage-device hierarchy, then: (Select all that apply. Marks will be deducted for incorrect answers)
(a)
The capacity and access time both increase
(b)
The cost and capacity both decrease
(c)
The capacity and access time both decrease
(d)
The frequency of access to the memory by the processor increases
(e)
The capacity increases and the access time decreases
Feedback:
According to storage hierarchy, when going down, the speed becomes slower, the cost decreases, the capacity increases, and access time increases too.
Q06
Suppose we are going up the storage-device hierarchy, then: (Select all that apply. Marks will be deducted for incorrect answers)
(a)
The cost and speed both increase
(b)
We move from volatile to non-volatile storage
(c)
The cost and capacity both decrease
(d)
The capacity and speed both increase
(e)
The capacity increases and the speed decreases
Feedback:
According to storage hierarchy, when going up, the speed and cost increase but the access time and the capacity both decrease.
Q07
In Priority Scheduling a priority number (integer) is associated with each process. The CPU is allocated to the process with the highest priority. The problem of starvation in priority scheduling is resolved by ____________________?
(Select all that apply – marks will be deducted for incorrect answers)
(a)
Aging
(b)
Increasing the priority of all processes
(c)
Decreasing the priority of all processes
(d)
Increasing the priority of the most recent process
(e)
Using a small time quanta
Feedback:
In priority scheduling, a low priority process can suffer from Starvation, if there is a continuous inflow of high priority processes in the system. In order solve this problem, we can periodically, let’s say every fifteen minutes, increase the priority of low priority processes.

Thus, after some time, the low priority process would become one of the high priority processes and get a chance to execute on CPU. This technique is known as Aging.
Q08
(a)
(b)
(c)
(d)
(e)
In which one(s) of the following scheduling policies can the longer jobs suffer from starvation?
(Select all that apply – marks will be deducted for incorrect answers)
Shortest Job First (SJF)
First Come First Serve (FCFS)
Round Robin (RR)
Shortest Remaining Time First
Priority Scheduling
Feedback:
Longer jobs cannot suffer from Starvation in FCFS and RR policies. In FCFS the execution order is defined according to the arrival of processes and every process (whether short or long, low or high priority) will be executed according to this order. In RR, we execute every process in a cyclic fashion for a time-quantum, therefore, all processes are executed.
However, in SJF, SRTF and PS, starvation can occur, if there is a sufficient supply of new processes with shorter length / remaining time or higher priority. The longer / low priority processes can suffer from starvation in such situations.
Q09
Which of the following statement(s) is/are correct?
(Select all that apply. Marks will be deducted for incorrect answers)
(a)
Short-term scheduler is invoked frequently (after a few milliseconds) and the long-
(b)
term scheduler is invoked infrequently (every few seconds)
Mid-term scheduler controls the degree of multiprogramming.
(c)
(e)
The short-term scheduler must be simple and fast, whereas the long-term scheduler
(d)
may be more complex and slower.
Long-term scheduler can be the only scheduler in a system; the short term and mid- term schedulers are considered optional.
The short-term scheduler moves processes from the waiting and blocked queues into the ready queue and controls the number of active processes in the system.
Feedback:
The short-term scheduler is invoked frequently (after every few milliseconds) while the long- term scheduler is invoked infrequently (after every few seconds). The mid-term scheduler also controls the degree of multiprogramming by moving processes in / out of the secondary storage (virtual memory). The short-term scheduler must be simple and fast, as it is executed

often; whereas the long-term scheduler can be more complex and slower, as it is invoked after every few seconds. The short-term scheduler is necessary for scheduling processes on the CPU. The short-term scheduler does not move processes from the waiting or blocked queues into the ready queue, it selects processes from the ready queue and dispatches them on the CPU for execution.
Q10
(a)
(b)
Which of the following statement(s) is/are incorrect?
(Select all that apply. Marks will be deducted for incorrect answers)
Short-term scheduler is invoked frequently (after a few milliseconds) and the long- term scheduler is invoked infrequently (every few seconds)
A mid-term scheduler controls the degree of multiprogramming.
(c)
The short-term scheduler may be complex and slower, whereas the long-term
scheduler must be simple and fast.
(d)
(e)
A long-term scheduler can be the only scheduler in a system; the short term and
medium-term schedulers are considered optional.
The short-term scheduler moves processes from the waiting and blocked queues
into the ready queue and controls the number of active processes in the system.
Feedback:
The short-term scheduler is invoked frequently (after every few milliseconds) while the long- term scheduler is invoked infrequently (after every few seconds). The mid-term scheduler also controls the degree of multiprogramming by moving processes in / out of the secondary storage (virtual memory). The short-term scheduler must be simple and fast, as it is executed often; whereas the long-term scheduler can be more complex and slower, as it is invoked after every few seconds. The short-term scheduler is necessary for scheduling processes on the CPU. The short-term scheduler does not move processes from the waiting or blocked queues into the ready queue, it selects processes from the ready queue and dispatches them on the CPU for execution.

Q11
(a)
(d)
(e)
Which of the following is/are not a characteristic(s) of a device driver? (Select all that apply. Marks will be deducted for incorrect answers)
It is concerned with buffering blocks of data going in/out of the device
(b)
(c)
It is responsible for moving data between peripheral devices and local storage
The device driver communicates directly with the device controller
It presents a uniform interface of the device to the rest of the OS
The device driver handles the interrupts generated by the peripheral device
Feedback:
The device driver is a software that communicates directly with the device controller and provides the rest of the OS with a uniform interface to the device; therefore, the device becomes recognizable to the OS. The buffering of blocks of data going in / out of the device is done by the device controller. Also, moving data between the peripheral device and local storage is done by the device controller. The interrupts from the device are handled by the interrupt service routines.
Q12
(a)
(b)
(c)
(d)
(e)
Which of the following is/are characteristic(s) of a device driver? (Select all that apply. Marks will be deducted for incorrect answers)
It enables the device to be recognisable by the OS
It provides an interface between the user applications and the device
It communicates directly with the peripheral device
It handles the interrupts generated by the peripheral device
It communicates directly with the device controller
Feedback:
The device driver is a software that communicates directly with the device controller and provides the rest of the OS with a uniform interface to the device; therefore, the device becomes recognizable to the OS. To start an I/O operation, the device driver loads the appropriate registers within the device controller therefore, a device driver directly talks to a device controller (not the device).
The device driver does not provide an interface between the user applications and the device, rather it is an interface between the OS and the device controller / device. Also, the device driver does not directly talk to the device; it communicates with the respective device controller. The interrupts from the device are handled by the interrupt service routines.

Q13
(a)
Which of the following statement(s) is/are correct for preemptive scheduling policies? (Select all that apply. Marks will be deducted for incorrect answers)
A process can be interrupted, and the CPU switched to execute a different process.
(b)
The waiting and response times are reduced compared to non-preemptive
(c)
(d)
(e)
scheduling.
The overall throughput of the system is guaranteed to be better than with non- preemptive scheduling policies.
The context switching overhead is lower than the with non-preemptive policies.
The preemptive scheduling is better for computationally intensive processes.
Feedback:
In preemptive scheduling, a process can be preempted in the middle of its execution to execute another process, which may be a high-priority or shorter process. Therefore, the waiting and response times are reduced as compared to non-preemptive policies. However, we cannot say that the throughput of the system will be better than non-preemptive policies, as more context switches are expected in preemptive policies, therefore the throughput is usually lower as the context switching overhead is higher. Lastly, preemptive scheduling policies are better for interactive process (not for the computationally intensive ones, which would perform better if there were less context switches).
Q14
(a)
Which of the following statement(s) is/are correct for non-preemptive scheduling policies? (Select all that apply. Marks will be deducted for incorrect answers)
The CPU is allocated to the process until it terminates or switches to the waiting
(b)
state
When any process enters the running state, it will always be kept in the running state until it finishes its execution.
(c)
(d)
(e)
The process may yield the CPU to other processes
Round robin is an example of non-preemptive scheduling
Non-preemptive scheduling is suitable when responsiveness is important
Feedback:
In non-preemptive scheduling, a process cannot be preempted in the middle of its execution to execute another process. It is up to the process to continue its execution until it terminates or switches to a waiting state, as a result of a system call / IO operation. The process itself may also decide to yield (release) the CPU after some time (cooperative scheduling).
It is incorrect to say that a process in running state (in non-preemptive policies) will always be kept in the running state until it finishes its execution because the process may get blocked / moved to waiting state as a result of a system call or IO operation.
Round Robin is a preemptive scheduling policy and lastly, non-preemptive scheduling policies

are better for computationally intensive processes (not for the interactive processes, which would perform better if we could provide quicker responses i.e. allow for more context switching).
Q15
Consider three compute bound processes with 10, 6 and 4 units of burst time. Let us assume that these processes arrive at 0, 2 and 6 units of time respectively. For the Shortest Remaining Time First (SRTF), how many context switches are needed? Do not consider the context switches at time 0 or at the end.
(a)
3
(b)
1
(c)
2
(d)
4
(e)
5
Feedback:
For the given set of processes, here is the SRTF schedule:
There will be 3 context switches in this schedule, as highlighted in the yellow cells above.
P1
P1
P2
P2
P2
P2
P2
P2
P3
P3
P3
P3
P1
P1
P1
P1
P1
P1
P1
P1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Q16
A process executes the following code for(i=1;i<=N;i++) fork(); How many new processes will be created from the execution of above code? (a) 2N –1 (b) 2N (c) 2(N+1) (d) N (e) 2(N-1) Feedback: The for loop will execute from 1 to N i.e. a total of N times. During each iteration, we invoke the fork() system call once, therefore duplicating the current process. When the fork() system call is invoked for the first time, we already have a parent process, therefore a total of 2N – 1 new processes will be created as a result of this for loop’s execution. Q17 (a) (c) (d) (e) A Context Switch is the mechanism to store and restore the state or context of a CPU in the Process Control block so that a process’ execution can be resumed from the same point later. In which one(s) of the following scenarios will the context switch NOT happen? (Select all that apply. Marks will be deducted for incorrect answers) When the OS kernel shares the user process image, and the user process makes a (b) system call. When the OS kernel is executed as a non-process kernel and the user process makes a system call. When the kernel functions are executed as separate processes and a hardware interrupt occurs. When the OS kernel is executed as a non-process kernel and a hardware interrupt occurs. When the OS functions execute as separate processes in kernel mode, and the user process makes a system call. Feedback: When the OS kernel shares the user process image, and the user process makes a system call, then the context switch will not happen, as the system call will be executed within the same process’ context. Only mode switch will take place i.e. from user mode to kernel mode. In all other cases, such as non-process kernel, kernel as a set of separate processes and when the interrupts occur, context switch will take place. Q18 Your computer system uses Round Robin scheduler and is not very responsive and so you decide to change the scheduling time quantum from 10 msec to 2 msec. Now the performance is even worse. Why is this happening? (Select all that apply. Marks will be deducted for incorrect answers) (a) Extra context switches are taking place (b) The disc is busy with additional I/O and creates a bottleneck (c) Your graphics processor is overloaded with the additional work in window updates (d) The I/O bus is overloaded and cannot perform the additional operations (e) You have run out of physical memory and so the operating system must spend more time managing virtual memory Feedback: If you decrease the time quantum then this will mean that the maximum time that a process will be allocated is decreased. Therefore, there will be significantly more context switches (up to 5 times in this case, depending on how the jobs behave). Context switches are expensive and take time that is no longer available to the processes. Q19 Consider the following set of processes: Processes Arrival Time Burst Time P1 0.0 8ms P2 2.0 10 ms P3 4.0 3ms What is the average response time assuming SRTF CPU scheduling policy? (a) 3.00 ms (b) 11.00 ms (c) 4.00 ms (d) 3.33 ms (e) 6.67 ms Feedback: For the given set of processes, here is the SRTF schedule: Response Time for P1 = (Execution Start – Arrival Time) = (0 – 0) = 0 ms Response Time for P2 = (Execution Start – Arrival Time) = (11 – 2) = 9 ms Response Time for P3 = (Execution Start – Arrival Time) = (4 – 4) = 0 ms AverageResponseTime=(0+9+0)/3=3.00ms. P1 P1 P1 P1 P3 P3 P3 P1 P1 P1 P1 P2 P2 P2 P2 P2 P2 P2 P2 P2 P2 0 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 Q20 Consider the following set of processes: Processes Arrival Time Burst Time P1 0.0 8ms P2 2.0 10 ms P3 4.0 3ms What is the average turnaround time assuming SRTF CPU scheduling policy? (a) 3.00 ms (b) 11.00 ms (c) 4.00 ms (d) 3.33 ms (e) 6.67 ms Feedback: For the given set of processes, here is the SRTF schedule: Response Time for P1 = (Process Completion – Arrival Time) = (11 – 0) = 11 ms Response Time for P2 = (Process Completion – Arrival Time) = (21 – 2) = 19 ms Response Time for P3 = (Process Completion – Arrival Time) = (7 – 4) = 3 ms Average Turnaround Time = (11 + 19 + 3) / 3 = 11.00 ms. P1 P1 P1 P1 P3 P3 P3 P1 P1 P1 P1 P2 P2 P2 P2 P2 P2 P2 P2 P2 P2 0 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0