MidTerm (Solution) - 5A
MidTerm (Solution) - 5A
Q1
a) Name the six main function of kernel in OS? (6 Marks)
Solution:
• scheduling processes
• resource allocation
• device management
• interrupt handling
• memory management
• process management.
b) What are the three cases when the control must transfer the from
user program to the kernel (5 Marks)
Solution:
1) First, a system call: when a user program asks for an operating
system service,
2) Second, an exception: when a program per- forms an illegal
action. Examples of illegal actions include divide by zero, attempt
to access memory for a PTE that is not present, and so on.
3) Third, an interrupt: when a device generates a signal to indicate
that it needs attention from the operating system. For example,
a clock chip may generate an interrupt every 100 msec to allow
the ker- nel to implement time sharing. As another example,
when the disk has read a block from disk, it generates an
interrupt to alert the operating system that the block is ready to
be retrieved.
In multiprogramming, the process can be In this process, two or more users can use
executed by a single processor. a processor in their terminal.
Multiprogramming OS has no fixed time Time-sharing OS has a fixed time slice.
slice
Windows Unix
1. Modularity
2. Easy Debugging
3. Easy Update
4. No direct access to hardware
5. Abstraction
Q2 a) With the help of a diagram, show the steps involve in the process of
context switching between two process P1 and P2. (10 Marks)
Solution
#include <stdio.h>
#include <unistd.h>
int main()
{
if (fork() || fork())
fork();
printf(" print ");
return 0;
}
a. Show with the help of a diagram that how many process are created?
Solution