Question 1: [Marks : 02]
A single processor can run only one program at a time. Operating System installed on the machine interacts as intermediary between the hardware of the system and users. How does an operating system make multiprogramming possible by using single processor?
In a multi programmed system, the operating system simply switches to, and executes another job.
When that job needs to wait, the CPU simply switches to another job and so on. The CPU is switched from P1 to P2 when P1 finishes its CPU burst and needs to wait for an event, and vice versa when P2 finishes it CPU burst and has to wait for an event. This means that when one process is using the CPU, the other is waiting for an event (such as I/O to complete). This increases the utilization of the CPU and I/O devices as well as throughput of the system. In our example below, P1 and P2 would finish their execution in 10 time units if no multiprogramming is used and in six time units if multiprogramming is used.
All jobs that enter the system are kept in the job pool. This pool consists of all processes residing on disk awaiting allocation of main memory. If several jobs are ready to be brought into memory, and there is not enough room for all of them, then the system must choose among them. This decision is called job scheduling. In addition if several jobs are ready to run at the same time, the system must choose among them.
Question 2: [Marks : 03]
Keeping in mind the Unix/Linux process management; do you think that a parent process can terminate one of its child processes? Give at least two reasons to support your answer.
A parent may terminate the execution of one of its children for a variety of reasons, such as:
The child has exceeded its usage of some of the resources that it has been allocated. This requires the parent to have a mechanism to inspect the state of its children. The task assigned to the child is no longer required. The parent is exiting, and the operating system does not allow a child to continue if its parent terminates. .On such a system, if a process terminates either normally or abnormally, then all its children must also be terminated.This phenomenon referred to as cascading termination, is normally initiated by the operating system.
Considering an example from UNIX, we can terminate a process by using the exit system call, its parent process may wait for the termination of a child process by using the wait system call. The wait system call returns the process identifier of a terminated child, so that the parent can tell which of its possibly many children has terminated. If the parent terminates however all its children have assigned as their new parent, the init process. Thus the children still have a parent to collect their status and execution statistics.
Question 3: [Marks : 05]
Consider a scenario when multiple processes are running in a system and CPU is switching among processes. In multiprogramming, the main issue is CPU protection. If a process doesn’t relinquish CPU for a long or infinite period of time then how will you prevent the user process or program from getting stuck in an infinite loop or not calling system services and never returning control to the CPU? Write down all necessary steps to accomplish CPU protection in this scenario.
In addition to protecting I/O and memory, we must ensure that the operating system maintains control. We must prevent the user program from getting stuck in an infinite loop or not calling system services and never returning control to the CPU. To accomplish this we can use a timer, which interrupts the CPU after specified period to ensure that the operating system maintains control. The timer period may be variable or fixed. A fixed-rate clock and a counter are used to implement a variable timer. The OS initializes the counter with a positive value. The counter is decremented every clock tick by the clock interrupt service routine. When the counter reaches the value 0, a timer interrupt is generated that transfers control from the current process to the next scheduled process. Thus we can use the timer to prevent a program from running too long. In the most straight forward case, the timer could be set to interrupt every N millisecond, where N is the time slice that each process is allowed to execute before the next process gets control of the CPU. The OS is invoked at the end of each time slice to perform various housekeeping tasks.
Another use of the timer is to compute the current time. A timer interrupt signals the passage of some period, allowing the OS to compute the current time in reference to some initial time. Load-timer is a privileged instruction.
Question 4: [Marks : 05]
Both types of I/O bound as well as CPU bound processes are executed by the processor. How can you differentiate between I/O bound and CPU bound processes? Describe one typical application for I/O bound and CPU bound.
IO bound processes: spend more time doing IO than computations, have many short CPU bursts.Word processors and text editors are good examples of such processes.
CPU bound processes: spend more time doing computations, few very long CPU
“I/O-bound programs have the property of performing only a small amount of computation before performing IO. .Such programs typically do not use up their entire CPU quantum. CPU-bound programs, on the other hand, use their entire quantum without performing any blocking IO operations. Consequently, one could make better use of the computer’s resources by giving higher priority to I/O-bound programs and allow them to execute ahead of the CPU-bound programs.DOWNLOAD SOLUTION HERE