SolMid1_OS19
SolMid1_OS19
SolMid1_OS19
Q1) What are the benefits of using threads? What resources are used when a thread is created? How do
they differ from those used when a process is created? (20 points)
Thread creation uses fewer resources than process creation. Creating a process requires:
- Allocating a process control block (PCB).
- A memory address space and stack
- List of open files, and allocated resources.
Q2) Consider the following set of processes, with the length of the CPU-burst time given in milliseconds: (24
points)
Process P1 P2 P3 P4
Arrival Time 0.0 1.0 2.0 4.0
Burst Time 8 4 1 2
1. What is the average turnaround and waiting times for these processes with the FCFS scheduling algorithm?
2. Repeat part (a) for the non-preemptive SJF scheduling algorithm?
3. Repeat part (a) for the preemptive SJF scheduling algorithm?
a- FCFS
P1 P2 P3 P4
8 12 13 15
Turnaround Time:
P1 = 8, P2= 12 – 1 = 11, P3 = 13 – 2 = 11, P4 = 15 – 4 = 11
Average Turnaround Time = (8 + 11 + 11 + 11) / 4 = 10.25
Waiting Time:
Aswan University 4th Year
Faculty of Engineering Mid-Term Exam, (2020/2019)
Operating Systems Time allowed : 1.5 Hrs.
P1 = 0, P2= 8 – 1 = 7, P3 = 12 – 2 = 10, P4 = 13 – 4 = 9
Average Waiting Time = (0 + 7 + 10 + 9) / 4 = 6.5
b- Non-Preemptive SJF
P1 P3 P4 P2
8 9 11 15
Turnaround Time:
P1 = 8, P2= 15 – 1 = 14, P3 = 9 – 2 = 7, P4 = 11 – 4 = 7
Average Turnaround Time = (8 + 14 + 7 + 7) / 4 = 9
Waiting Time:
P1 = 0, P2= 11 – 1 = 10, P3 = 8 – 2 = 6, P4 = 9 – 4 = 5
Average Waiting Time = (0 + 10 + 6 + 5) / 4 = 5.25
c- Preemptive SJF
P1 P2 P3 P2 P4 P1
1 2 3 6 8 15
Turnaround Time:
P1 = 15, P2= 6 – 1 = 5, P3 = 3 – 2 = 1, P4 = 8 – 4 = 4
Average Turnaround Time = (15 + 5 + 1 + 4) / 4 = 6.25
Waiting Time:
P1 = 8 – 1 = 7, P2= 3 - 2 = 1, P3 = 0, P4 = 6 – 4 = 2
Average Waiting Time = (7 + 1 + 0 + 2) / 4 = 2.5
Q3) What is the main function of short-term, medium-term and long-term schedulers? Describe the
differences between them in terms of response time and frequency of use? (21 points)
Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready
queue (Selects processes from spool (disk) and load them into memory for execution).
Short-term scheduler (or CPU scheduler) – selects which process should be executed next and
allocates CPU (Selects a process from the ready queue).
Medium-term scheduler Remove processes from memory and from active contention for the CPU and
reduces the degree of multiprogramming
1- The frequency of their execution.
The Short-term scheduler must select a process for the CPU frequently (Often it executes at least
once every 100 milliseconds).
The Long-term scheduler executes much less frequently (There many minutes between the creation of
new processes).
The Medium-term scheduler is invoked only if there is a performance degradation in the system.
Aswan University 4th Year
Faculty of Engineering Mid-Term Exam, (2020/2019)
Operating Systems Time allowed : 1.5 Hrs.
Q4) What are the main advantages of the micro-kernel approach to system design? How do user
programs and system services interact in a microkernel architecture? What are the disadvantages of
using the microkernel approach? (15 points)
Easier to extend the operating system. All new services are added to consequently do not
require modification of the kernel.
Since the microkernel is a smaller kernel, It is easier to port the operating system to new
architectures.
More secure. Most of the services are running as user (rather than kernel) processes.
More reliable. If a service fails, the rest of the operating system remains safe
a simpler kernel design
- User programs and system services interact in a microkernel architecture by using interprocess
communication mechanisms such as messaging. These messages are conveyed by the operating system.
- The primary disadvantage of the microkernel architecture are the overheads associated with
interprocess communication and the frequent use of the operating system’s messaging functions in
order to enable the user process and the system service to interact with each other.