Sunteți pe pagina 1din 6

Q1. Draw The Process State diagram. describe the different states.

Ans:

A process goes through a series of discrete process states.

New State: The process being created.

Running State: A process is said to be running if it has the CPU, that is, process actually using the CPU at that particular
instant.

Blocked (or waiting) State: A process is said to be blocked if it is waiting for some event to happen such that as an I/O
completion before it can proceed. Note that a process is unable to run until some external event happens.

Ready State: A process is said to be ready if it use a CPU if one were available. A ready state process is runable but
temporarily stopped running to let another process run.

Terminated state: The process has finished execution.

Q2. Describe the transitions the states in process state diagram.


Ans: Following are six(6) possible transitions among above mentioned five (5) states
Transition 1 occurs when process discovers that it cannot continue. If running process initiates an I/O
operation before its allotted time expires, the running process voluntarily relinquishes the CPU.
This state transition is: Block (process-name): Running Block.
Transition 2 occurs when the scheduler decides that the running process has run long enough and it is
time to let another process have CPU time.
This state transition is: Time-Run-Out (process-name): Running Ready.
Transition 3 occurs when all other processes have had their share and it is time for the first process to
run again
This state transition is: Dispatch (process-name): Ready Running.
Transition 4 occurs when the external event for which a process was waiting (such as arrival of input)
happens.
This state transition is: Wakeup (process-name): Blocked Ready.
Transition 5 occurs when the process is created.
This state transition is: Admitted (process-name): New Ready.
Transition 6 occurs when the process has finished execution.
This state transition is: Exit (process-name): Running Terminated.

Q3. Describe the bankers algorithm (both dead lock detection and resolve allocation algorithm. & bankers algorithm
Application.

Ans : This algorithm is very similar to deadlock detection algorithm. But in deadlock detection, requested resources are granted to
processes whenever possible ( this algorithm is static ). In the bankers algorithm decision is made dynamically whether the resource
allocation will potentially lead to deadlock.
This algorithm uses the same data ( as deadlock detection algorithm ): total amount of each resource in the system {Ri} i = 1,m ;
resources available
{Ai} i=1,m ; allocation matrix {Cij} i = 1,n; j = 1,m ; maximum matrix (maximum requirement or request of each process for each
resource).
In the algorithm steps, the auxiliary matrix Need = Maximum Allocation is used.
The strategy is as following: ensure that the system is in a safe state. When process makes a request for a set of resources, assume that
the request is granted, update the system state accordingly, and then determine if the result is a safe state. If so, grant the request and, if
not, block the process until it is safe to grant the request.
Safety algorithm (bankers algorithm)
Step 1
Initialize a temporary vector W (Work) to equal the available vector A.
Step 2
Find an index i (row i) such that
Needi = A
If no such row exists, the system will deadlock, since no process can run to completion
Step 3
If such a row is found, mark this process as finished, and add all its resources to W vector
A = A + Ci,*
Go to step 2, until either all processes are marked terminated ( in this case initial state is safe ), or until a deadlock occurs, in which the
state is not safe.
Resource request algorithm
Let the request vector Rij = k is coming, meaning that process Pi wants k instances of resource j . The following actions are taken:
Step 1
If Requesti < = Needi , go to step 2. Otherwise, error
Step 2
If Requesti < = Available , go to step 3. Otherwise, Pi must wait, since
resources are not available
Step 3
Modify the state ( the system pretend to have allocated the requested resources to process Pi )
Available = Available - Requesti
Allocationi = Allocationi + Requesti
Needi = Needi - Requesti
If the resulting state is safe, the transaction is completed and process Pi is allocated its resources. If new state is unsafe, then Pi must
wait for Requesti and the old state is restored.
Example
4 processes P1, P2, P3, P4 and 3 resources R1, R2, R3 ( with the total amounts 9, 3, and 6 units respectively ) are given. The initial
state is as:
Allocation

Maximum

Need

R1 R2 R3

R1 R2 R3

R1 R2 R3

P1

P2

P3

P4

Resource vector
Available vector

R1 R2 R3
9

Can any of the 4 processes be run to completion with the resources available? ( is this a safe state? )
Yes, process P2 can run until completion after assigning 1 unit of R3 to him.
Let us assume that this is accomplished. The resulting state now is as ( after P2 releases the resources! ):
Allocation

Maximum

R1 R2 R3

R1 R2 R3

Need
R1 R2 R3

P1

P2

P3

P4

Available vector

R1 R2 R3
6

Now, each of the remaining processes could be completed. Suppose, we choose P1, allocate the required resources, complete P1, and
return all of its resources to the available pool. The resulting state is:
Allocation

Maximum

R1 R2 R3

R1 R2 R3

Need
R1 R2 R3

P1

P2

P3

P4

Available vector

R1 R2 R3
7

Next, we can complete P3, resulting the state below:


Allocation

Maximum

R1 R2 R3

R1 R2 R3

Need
R1 R2 R3

P1

P2

P3

P4

Available vector

R1 R2 R3
9

Finally, we can complete P4.


At this point, all of the processes have been run to completion. Thus, the initial state is a safe state.
Consider the small different situation with the same example. Initial state is defined by the matrices:
Allocation

Maximum

Need

R1 R2 R3

R1 R2 R3

R1 R2 R3

P1

P2

P3

P4

Resource vector
Available vector

R1 R2 R3
9

Suppose that P1 makes the request for one additional unit each of R1 and R3; if we assume that request is granted, we will come to the
new state:
Allocation

Maximum

R1 R2 R3

R1 R2 R3

Need
R1 R2 R3

P1

P2

P3

P4

R1 R2 R3
Available vector

Is this a safe state? No, because each process will need at least 1 additional unit of R1, and there are none available. Thus, on the basis
of deadlock avoidance, the request by P1 should be denied and P1 should be blocked.

Q4. Draw Gann chest and find out Average turn-around time & waiting time for FCFS,SJF, Round Robin Algorithm.
Process

Arrival Time

Execution Time

P1

54

P2

134

P3

150

P4

85

Ans: For Solution this Question Please find the Sheet of cpu-scheduling.
Q5. What are the three main purposes of an operating system?
Ans : To provide an environment for a computer user to execute programs on computer hardware in a convenient and
efficient manner.
To allocate the separate resources of the computer as needed to solve the problem given. The allocation process should
be as fair and efficient as possible.
As a control program it serves two major functions: (1) supervision of the execution of user programs to prevent errors
and improper use of the computer, and (2) management of the operation and control of I/O devices.
Q6. What are the main differences between operating systems for mainframe computers and personal computers?
Ans: Generally, operating systems for batch systems have simpler requirements than for personal computers. Batch
systems do not have to be concerned with interacting with a user as much as a personal computer. As a result, an operating
system for a PC must be concerned with response time for an interactive user. Batch systems do not have such

requirements. A pure batch system also may have not to handle timesharing, whereas an operating system must switch
rapidly between different jobs.
Q7. What is the main difficulty that a programmer must overcome in writing an operating system for a real-time
environment?
Ans : The main difficulty is keeping the operating system within the fixed time constraints of a real-time system. If the
system does not complete a task in a certain time frame, it may cause a breakdown of the entire system it is running.
Therefore when writing an operating system for a real time system, the writer must be sure that his scheduling schemes
dont allow response time to exceed the time constraint.
Q4. Alocate The separate resorce of the computer
Q8. List the four steps that are necessary to run a program on a completely dedicated machine.
Ans :
a. Reserve machine time.
b. Manually load program into memory.
c. Load starting address and begin execution.
d. Monitor and control execution of program from console.
Q9. Threads

Ans : Despite of the fact that a thread must execute in process, the process and its associated threads are
different concept. Processes are used to group resources together and threads are the entities scheduled for
execution on the CPU. A thread is a single sequence stream within in a process. Because threads have some of
the properties of processes, they are sometimes called lightweight processes. In a process, threads allow
multiple executions of streams. In many respect, threads are popular way to improve application through
parallelism. The CPU switches rapidly back and forth among the threads giving illusion that the threads are
running in parallel. Like a traditional process i.e., process with one thread, a thread can be in any of several
states (Running, Blocked, Ready or Terminated). Each thread has its own stack. Since thread will generally call
different procedures and thus a different execution history. This is why thread needs its own stack. An operating
system that has thread facility, the basic unit of CPU utilization is a thread. A thread has or consists of a
program counter (PC), a register set, and a stack space. Threads are not independent of one other like processes
as a result threads shares with other threads their code section, data section, OS resources also known as task,
such as open files and signals.
Q10. Describe the booting process for a windows 7 system.
Ans : (1) As the hardware powers on, the BIOS begins executing from ROM and loads and
executes the bootstrap loader from the disk. (2) The NTLDR program is loaded from the root
directory of the identified system device and determines which boot device contains the
operating system. (3) NTLDR loads the HAL library, kernel, and system hive. The system hive
indicates the required boot drivers and loads them. (4) Kernel execution begins by initializing the
system and creating two processes: the system process containing all internal worker threads,
and the first user-mode initialization process: SMSS. (5) SMSS further initializes the system by

establishing paging files and loading device drivers. (6) SMSS creates two processes: WINLOGON,
which brings up the rest of the system, and CSRSS (the Win32 subsystem process).

S-ar putea să vă placă și