You are on page 1of 8

OPERATING SYSTEM ASSIGNMENT SUBMITTED BY UDDIPTTA UJJAWAL 11007877 B53 SUBMITTED TO Ramanpreet Kaur Lamba

Home Work-I Operating System

Course Code CSE316

Question 1. What happens on a context switch? Should context switches happen frequently or infrequently? Explain your answer. Ans: Switching the CPU to another process requires performing a state save of the current process and a state restore of a different process. This task is known as a context switch. When a context switch occurs, the kernel saves the context of the old process in its PCB and loads the saved context of the new process scheduled to run. Interrupts cause the operating to change a CPU from its current task and to run a kernel routine. So ,operation like context switch happens frequently in general purpose systems. Question 2. In a multiprogramming and time sharing environment, several users share the system simultaneously. This situation can result in various security problems. a) What are two such problems? b) Can we ensure the same degree of security in a time shared machine as we have in a dedicated machine? Explain your answer. Ans:a)Two such problem that occur multiprogramming and time sharing is : in case of

1.Dealock: It can be defined as a state where two process are having resources that is need by each of them and one cannot perform a execution if it doesnt have both resources and both

are waiting for the resources to be free and will wait for infinite time. This phenomena is known as deadlock. 2. Trap: A trap is a software generated interrupt caused either by an error or by specific request from user program. This erroneous program might modify other program. 3. Starvation: Starvation can be defined as a situation where a process has to wait indefinitely for certain amount of time . b)No, we cant assure the same security in time sharing machine as in Dedicated machine because in case of dedicated machine we have reserve machine time, manually loading of program into memory, loading of starting address and begin execution, manages execution of program through console. Question 3. What is the relationship between a guest OS and host OS in a system like VMware? What factors need to be considered in choosing the host OS? Ans:A guest OS is a virtual machine like VMware and host OS is operating system like windows, Mach etc. When one want to have two OS in a single pc then the idea of virtual machine comes into play. Instead of have two computer we use the concept of virtual machine like VMware. The fundamental idea behind virtual machine is to abstract hardware of a single computer (like disk drives, network interface card and so forth) into several different executing environment , thereby creating illusion that each separate environment is running its own private computer. The factor that are needed to be considered in choosing the host OS is :

1.Minidisk or physical shared disk: It makes it possible to share a mini disk and thus to share files . This scheme is modelled after a physical shared disk but is implemented by software . 2.NIC(network Interface card): It is possible to define a network of virtual machine, each of which can send information over the virtual communication network but is implemented in software. 3.CPU: the cpu must be virtually shared as the CPU of virtual machine. Question 4. Which of the following components of program state are shared across threads in a multithreaded process? a) Register values b) Heap Memory c) Global Variables d) Stack Memory Ans:c),d) i.e heap and global variable

Question 5. Consider the exponential average formula used to predict the length of the next CPU burst. What are the implications of assigning the following values to the parameters used by the algorithm? a. = 0 and T0 = 100 ms b. = 0.99 and T0 =10 ms Ans: a) If = 0 and T0 = 100 ms here the parameter control the relative weight of recent and past history. So if = 0 and

T0 = 100 ms then T1=T0 which imply that recent history has no effect ie. The current condition are assumed to be transient ). The formula always makes a prediction of 100

Milliseconds for the next CPU burst.


b)if = 0.99 and T0 =10 ms that is tends to be 1, therefore if =1 then T1=t0 i.e . only the most recent cpu burst matters(history is assumed to be old and irrelevant .The most

recent behavior of the process is given much higher weight than the past history associated with the process
Question 6 Draw a Gantt chart illustrating the execution of these processes using the FCFS scheduling algorithm, Round Robin with q=3 and SJF (Pre-emptive and non-pre-emptive).

What is the average process turnaround time? What is the average process waiting time?

Process CPU Burst Arrival Time P0 P1 P2 P3 2 10 6 3 0 1 5 7

Ans: FCFS Schedulling

P0 P3

P1

P2

0 18

2 21

12

1. Average turnaround time =(2+11+13+14)/4=10ms 2. Average waiting time =(0+1+7+11)/4=4.75ms

SJF Schedulling

The Gantt chart for the schedule using Round Robin where q=3
P0 P1 P2 P3 P1 P2 P1 P1

0 21

11

14

17

20

1. Average waiting time: (0+10+6+1)/4 = 4.25 2. Average Turnaround time : (2+20+12+4)/4=9.5 The Gantt chart for the schedule using SJF (nonpreemptive):
Ci C C C

0 21

12

15

1. Average waiting time: (0+1+10+5)/4=4 2. Average Turnaround time :(2+11+16+8)=9.25 The Gantt chart for the schedule using SJF (preemptive):

Ci

C

C

C

C

C

0 2 5 7 10 14 21 1. Average waiting time: (0+10+3+0)/4=3.25 2. Average Turnaround time : (2+20+10+3)/4=8.75;

You might also like