You are on page 1of 4

Question No 1 Provision of mechanisms for deadlock handling In a multiprogramming environment, several processes may compete for a finite number

r of resources. If a deadlock occurs, all waiting processes will never change their waiting state to running state again, resources are wasted and jobs will never be completed. Waiting for an event could be:

waiting for access to a critical section waiting for a resource Note that it is usually a non-preemptable (resource). preemptable resources can be yanked away and given to another. A deadlock situation can arise if and only if the following four conditation occur simultaneously in a system. the situations are: 1) Mutual Exclusion Only one process can use a resource at the same time. If another process request same resource, the process must be delayed until the resource has been released. 2) Hold and Wait

There must be one process that is having one resource and waiting for another resource that is being currently held by another process.

3) No Preemption

The situation in which any process can not pre-empt(killed) and can not be shared. 4) Circular wait condition

There must be a circular chain of two or more process. each process is waiting for a resource held by next member of the chain. Strategies for dealing with Deadlock

ignore the problem altogether ie. ostrich algorithm it may occur very infrequently, cost of detection/prevention etc may not be worth it.

detection and recovery avoidance by careful resource allocation prevention by structurally negating one of the four necessary conditions.

Creation and deletion of both user and system processes The processes in the system can execute concurrently for information sharing, computation speedup, modularity, and convenience. Concurren execution requires a mechanism for process creation and deletion. The required resources are given to the process when it is created, or allocated to it while it is running. When the process terminates, the OS needs to reclaim any reusable resources. Suspension and resumption of processes

In process scheduling, the OS needs to change the process's state to waiting or ready state when it is waiting for some resources. When the required resoureces are available, OS needs to change its state to running state to resume its execution.

Question No 2 Keep track of which parts of memory are currently being used and by whom In CPU scheduling, the CPU switches its attention among processes. When the OS does a context switch among processes it must ensure the execution of each process is done correctly. So, the OS must know which parts of memory are currently being used and by whom.

Decide which processes are to be loaded into memory when memory space becomes Available

When a process' state changes from swapped-out state to running state, its code and data have to be loaded into memory. So, OS must know which processes are to be loaded into memory and which remain swapped out.

Allocate and deallocate memory space as needed

When loading the code and data of a process into memory to execute it(swapped -> ready), the OS allocates the memory required to support its execution. When scheduler decides to swap a process out (ready/running -> swapped), the OS deallocates memory space has been used by the process.

Question No 3

System calls provide an interface between the process an the operating system. System calls allow user-level processes to request some services from the operating system which process itself is not allowed to do. In handling the trap, the operating system will enter in the kernel mode, where it has access to privileged instructions, and can perform the desired service on the behalf of userlevel process. It is because of the critical nature of operations that the operating system itself does them every time they are needed. For examples, for I/O a process involves a system call telling the operating system to read or write particular area and this request is satisfied by the operating system. Internet Explorer uses a system call routine to open port 80 (HTTP) to access the internet. System programs provide basic functioning to users so that they do not need to write their own environment for program development (editors, compilers) and program execution (shells). In some sense, they are bundles of useful system calls.

System calls allow user-level processes to request services of the operating system where as System programs can be thought of as bundles of useful system calls. They provide basic functionality to users so users do not need to write their own programs to solve common problems.