Arid Agriculture University, Rawalpindi: Office of The Controller of Examinations
Arid Agriculture University, Rawalpindi: Office of The Controller of Examinations
Arid Agriculture University, Rawalpindi: Office of The Controller of Examinations
To be filled by Student
Note:
1. Approximately paper solving time is 2.5 hrs, however submission time is till 48 hours.
2. Try to upload paper as soon as possible to avoid DOS error at server due to bulk subm
issions in late hours.
3. There are total five (5) questions in the paper.
4. Draw clearly and add diagrams/screenshots in your answer sheet (word file) wherever
required.
5. Make sure you have filled your Name and Reg. No. in the above provided space.
6. Upload the paper only through PC or laptop, Mobile submission is not allowed.
b. How does the distinction between kernel mode and user mode function as a rudimenta
ry form of protection (security)?
c. Describe three general methods for passing parameters to the operating system.
Solution. Q. No. 1:
A. An argument in favor of including popular applications with the operating system is that if
the application is embedded within the operating system, it is likely to be better able to take a
dvantage of features in the kernel and therefore have performance advantages over an applica
tion that runs outside of the kernel.
Arguments against embedding applications within the operating system typically dominate ho
wever:
1. the applications are applications and not part of an operating system
2. any performance benefits of running within the kernel are offset by security
vulnerabilities
3. it leads to a bloated operating system
B.
The distinction between kernel mode and user mode provides a rudimentary form of protecti
on in the following manner. Certain instructions could be executed only when the CPU is in k
ernel mode. Similarly, hardware devices could be accessed only when the program is executi
ng in kernel mode. Control over when interrupts could be enabled or disabled is also possible
only when the CPU is in kernel mode. Consequently, the CPU has very limited capability wh
en executing in user mode, thereby enforcing protection of critical resources.
C.
Three general methods used to pass parameters to the Operating System
1. Simplest: pass the parameters in registers
• In some cases, may be more parameters than registers
2. Parameters stored in a block, or table , in memory, and address of block passed as a
parameter in a register
3. Parameters placed, or pushed , onto the stack by the program and popped off the stac
k by the operating system
b. Some computer systems provide multiple register sets. Describe what happens when a
context switch occurs if the new context is already loaded into one of the register sets.
What happens if the new context is in memory rather than in a register set and all the r
egister sets are in use?
c. Assume that an operating system maps user-level threads to the kernel using the man
y-to-many model and that the mapping is done through LWPs. Furthermore, the syste
m allows developers to create real-time threads for use in real-time systems. Is it nece
ssary to bind a real-time thread to an LWP? Explain
Solution. Q. No. 2:
A.
The virtual memory subsystem and the storage subsystem are typically tightly coupled and re
quires careful design in a layered system due to the following interactions. Many systems allo
w files to be mapped into the virtual memory space of an executing process. On the other han
d, the virtual memory subsystem typically uses the storage system to provide the backing stor
e for pages that do not currently reside in memory. Also, updates to the file system are someti
mes buffered in physical memory before it is flushed to disk, thereby requiring careful coordi
nation of the usage of memory between the virtual memory subsystem and the file system.
For example, different components of an OS are related to each other would be the virtual
memory and the storage system. Having strong dependencies between components makes it
difficult to divide the layers.
B.
The CPU current register set pointer is changed to point to the set containing the new context,
which takes very little time. If the context is in memory, one of the contexts in a register set
mist be chosen and be moved to memory, and the new context must be loaded from memory
into the set. This process takes a little more time than on systems with one set of registers,
depending on how a replacement victim is selected.
C.
Yes. Timing is crucial to real-time applications. If a thread is marked as real-time but is not b
ound to an LWP, the thread may have to wait to be attached to an LWP before running. Consi
der if a real-time thread is running (is attached to an LWP) and then proceeds to block. While
the real-time thread is blocked, the LWP it was attached to has been assigned to another threa
d. When the real-time thread has been scheduled to run again, it must first wait to be attached
to an LWP.
By binding an LWP to a real-time thread we are ensuring that the thread will be able to run w
ith minimal delay once it is scheduled.
The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.
a. Draw four Gantt charts that illustrate the execution of these processes using the follow
ing scheduling algorithms: FCFS, SJF, non-preemptive priority (a smaller priority nu
mber implies a higher priority), and RR (quantum = 2).
b. What is the waiting time of each process for each of these scheduling algorithms?
c. What is the turnaround time of each process for each of the scheduling algorithms in p
art a?
Solution. Q. No. 3:
SJT (Non-Preemptive)
P2 P1 P4 P5 P3
0 1 3 7 12 20
Performance Statistics:
Process Arrival Time Burst Time Priority Finish Time Turnaround Time Waiting Time
P1 0 2 2 3 3 1
P2 0 1 1 1 1 0
P3 0 8 4 20 20 12
P4 0 4 3 7 7 3
P5 0 5 2 12 12 7
Average 8.6 4.6
SJT (Preemptive)
In this case the processes all arrive at the same time. This method turned out to be the
same as non-preemptive SJF.
P2 P1 P4 P5 P3
0 1 3 7 12 20
Process Arrival Time Burst Time Priority Finish Time Turnaround Time Waiting Time
P1 0 2 2 3 3 1
P2 0 1 1 1 1 0
P3 0 8 4 20 20 12
P4 0 4 3 7 7 3
P5 0 5 2 12 12 7
Average 8.6 4.6
Non-preemptive Priority
P2 P1 P5 P4 P3
0 1 3 8 12 20
Performance Statistics:
Process Arrival Time Burst Time Priority Finish Time Turnaround Time Waiting Time
P1 0 2 2 3 3 1
P2 0 1 1 1 1 0
P3 0 8 4 20 20 12
P4 0 4 3 12 12 8
P5 0 5 2 8 8 3
Average 8.8 4.8
Round Robin
P1 P2 P3 P4 P5 P1 P3 P4 P5 P3 P4 P5 P3 P4 P5 P3 P5 P3 P3 P3
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Performance Statistics:
Process Arrival Time Burst Time Priority Finish Time Turnaround Time Waiting Time
P1 0 2 2 6 6 4
P2 0 1 1 2 2 1
P3 0 8 4 20 20 12
P4 0 4 3 14 14 10
P5 0 5 2 17 17 12
Average 11.8 7.8
P6 P10 P8 P7 P9 P3 P5 P2 P1 P4
0 14 19 27 34 47 51 69 75 77 87
Performance Statistics:
Process Arrival Time Burst Time Priority Finish Time Turnaround Time Waiting Time
P1 43 2 63 77 34 32
P2 36 6 46 75 39 33
P3 20 4 31 51 31 27
P4 60 10 62 87 27 17
P5 30 18 63 69 39 21
P6 0 14 46 14 14 14
P7 15 7 31 34 19 12
P8 12 8 31 27 15 7
P9 15 13 31 47 32 19
P10 10 5 31 19 9 4
Solution. Q. No. 5:
A.
There is no restriction or formula to apply on different process we have our own choice to
apply algorithm on different type of processes but generally follow
System process => round robin
Interactive process => shortest job first
Batch System process => first come first serve
B.
The scheduling algorithm I’ll implement on MLQ itself will be
System process => Shortest Job First (sjf)
Interactive process => Shortest Job First (sjf)
Batch system process => First Come First Serve (fcfs)
There is no restriction to apply different algorithm on different process, we have the authority
to apply the same algorithm on different processes
C.
System process
Processes Burst time
P1 2
P2 4
P3 8
Interactive process
Processes Burst time
P4 2
P5 4
P6 8
Batch processes
Processes Burst time
P7 2
P8 2
P9 2
System process having higher priority the CPU execute these processes first then CPU
execute interactive and then batch processes
Gantt chart
P1 P2 P3 P4 P5 P6 P7 P8 P9
0 2 6 14 16 20 28 30 32
34
If CPU execute batch process then interactive process come then CPU switch to execute
interactive process