You are on page 1of 1

Indian Institute of Information Technology Design & Manufacturing Kancheepuram Chennai-127

COM 301T OPERATING SYSTEMS - ONLINE ASSESSMENT I (OA1) SEP ’ 20 Max: 15 MARKS

Instructions: This is an open book / internet assessment.

 All Questions should carry the relevant explanation / trace / reasoning. Just answers alone would not be evaluated. Evaluation
would be proportional to the steps / trace / explanation depth. State and make any valid assumptions wherever required.
 Questions that require you to give the output should be instantiated with a complete trace and explanation as well. Output
value would only carry proportional weightage corresponding to the trace.
 Questions that require you to develop codes / solutions should also contain the logic explanation with an apt trace.

Q1. [2.5 Marks ] Develop a C program that executes processes in a top down fashion (most recent one to be created to be executed
the last...) [you can list the code assuming two fork calls in a consecutive fashion]

Q2 [3.5 Marks] Given the following process setup, generate the GANTT chart following (i) SJF (ii) RR – q=2 (iii) HRRN and (iv)
SRT scheduling strategies. Compute the TAT, Wait Time under each strategy and compare the four strategies with respect to
efficiency measure for schedulers. {(1,0,3),(2,2,6),(3,4,4),(4,6,5),(5,8,2) // Read as (pid,AT,ST)}

Q3[3.5 Marks]
(a) Give the output of the following C code: (assume no syntax errors)
main( ) { int a = 10;
if ((fork ( ) == 0))
a++;
printf (“%d ”, a ); }

(b) The following two processes P1 and P2 that share a variable B with an initial value of 2 execute concurrently. Count the number of
distinct values of B after execution.
P1() { C = B – 1; B = 2*C; } P2(){ D = 2 * B; B = D - 1; }

Q4 [3 Marks] Say True or False with apt Justifications for each: (a) The exec () system call creates a new process.

(b) After a process creates a child process using fork(), both execute the program of the parent process in its entirety.

(c) In a program, if an exec () precedes the call to fork (), we will end up with 3 processes - one that will run the main program,
second that will run the program called by exec (), and third that will run another copy of main program from the point of fork ().
(d) A shell runs a program by calling fork () and exec ().

(e) The fork () system call returns 0 when the new process finishes.

Q5[2.5 Marks] Assume you run the following code on a Linux OS (assume preemptive scheduling policy and there are no other
interfering processes in the system. Exe “good long executable” runs for 100 seconds, prints the line “Welcome to OS Course ” to
screen, and terminates. On the other hand, the file “bad executable” does not exist and will cause the exec system call to fail.

int ret1 = fork();


if(ret1 == 0) { //Child 1
printf("Child 1 started\n");
exec("good_long_executable");
printf("Child 1 finished\n");
}
else { //Parent
int ret2 == fork();
if(ret2 == 0) { //Child 2
sleep(10); //Sleeping allows child 1 to begin execution
printf("Child 2 started\n");
exec("bad_executable");
printf("Child 2 finished\n");
} //end of Child 2
else { //Parent
wait();
printf("Child reaped\n"); wait(); printf("Parent finished\n");}}Write down the output of the above program.

You might also like