Midterm Exam Version 2 With MCQ Correction

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Midterm EXAM

Part 1 (10 pts)

This part contains multiple choice questions. You should select only one choice for each question, the
most appropriate one. There is no partial credit.
1 ) The PCB of a process must contain some arrays as :
a) PID, Delivered signals, signal mask and signal handlers
b) Delivered signals, File descriptors Table and signal handlers
c) Delivered signals, state, and signal handlers
2 ) An interrupt is :
a) A hardware interruption raised by I/O devices that need OS attention.
b) An interface between kernel mode and user mode.
c) A mechanism used by application programs for inter-process communication (IPC).
d) All of the above.
e) None of the above.
3) In a multiprogrammed and multitasked system, which transitions are possible:
a) Running state to ready state
b) Waiting state to ready state
c) Ready state to running state
d) All of the above.
e) None of the above.
4) A process executed the function pause(). When the OS receives a signal, it will move the process
from :
a) Waiting state to running state
b) Waiting state to ready state
c) Ready state to running state
d) All of the above.
e) None of the above.
5) A process has at least one thread of control because
a) it has already a stack segment
b) it has already a heap segment
d) All of the above.
e) None of the above.
6) The wait() system call in POSIX/UNIX returns
a) 0 if the child is terminated
b) 0 if the child is terminated with exit
d) 0 if the child is terminated with signal
e) None of the above.

7) The ----------------- is a serious problem in premptive priority algorithm that could be fixed with -----
--------- .
a) Priority inversion - aging
b) Aging – dynamic priority
c) Starvation - aging
d) None of the above.

8) The Bootstrap is (Choose the False statement)


a) Special code that is saved in the ROM.
b) Special code that synchronises between processes.
c) Special code that initializes the system and loads the kernel

9) In Multi Level Algorithm, when a new process with higher priority comes
a) It interrupts the active process
b) The active process continues its quantum then the new process is executed
d) None of the above.

10) The kill() system call


a) sends a signal to a process
b) receives a signal from a process
c) blocks a process until the reception of a signal
d) None of the above.

Part 2 (30 pts) Process Management

Question 1. (15 pts)


Draw the process tree generated by the following code ? (explain your response)
Draw the process tree generated by the following code
int main() {if (! Fork()) fork();}

Question 2. (15 pts)


Write a program C that executes a linux command passed as an argument.
Example : program ls -l /bin

Part 3 (30 pts) Scheduling


Process Arrival time Burst size
P1 0 4 CPU Burst
4 I/O Burst
4 CPU Burst
4 I/O Burst
4 CPU Burst

P2 2 8 CPU Burst
1 I/O Burst
8 CPU Burst

P3 3 2 CPU Burst
1 I/O Burst
2 CPU Burst

P4 7 1 CPU Burst
1 I/O Burst
1 CPU Burst
1 I/O Burst
1 CPU Burst

Consider the workload above, showing the arrival times, burst sizes (CPU Burst and I/O
Burst) and priorities of several processes. The scheduler is Round Robin with Q=3. The
processes are using the same Input/Output Device and they are served with FIFO.
1. Fill the Grid to indicate the process states corresponding to the schedule produced by
this algorithm. (20 pts)
2. Calculate the average treatment time and the average waiting time. (5 pts)
3. What is the main disadvantage of this algorithm? How it could be fixed? (5 pts)

4. Consider now that P1 and P2 have the same critical section in their last cpu bursts time.

Change the scheduling when synchronisation is insured with: Disabling interreption, TSL and
semaphores.
Part 4 (30 pts) Inter process Communication

Write a program that creates two children communicating with an unnamed pipe.
The first child sends its pid to the second through the pipe.
The second child use the pid to send to the first child the signal SIGUSR1 that kills him.
The parent must wait for his children.

You might also like