You are on page 1of 3

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, PILANI

K K BIRLA, GOA-CAMPUS
OPEN BOOK, Quiz -1
Subject Name: Operating Systems (CS F372), Time: 40 Minutes Max. Marks: 30

Name: ID. No:

1. Consider the following code segment:


pid_t pid;
pid = fork();
if (pid == 0) { /* child process */
fork();
thread_create( . . .);
}
fork();
a. How many unique processes are created? Explain your answer.
b. How many unique threads are created? Explain your answer.

2. Using the program shown in below, explain nums[i] *= -i;


what the output will be at lines X and Y. Explain printf("CHILD: %d ",nums[i]); /* LINE X */
your answer. }

#include <sys/types.h> }
#include <stdio.h> else if (pid > 0) {
#include <unistd.h> wait(NULL);
#define SIZE 5 for (i = 0; i < SIZE; i++)
int nums[SIZE] = {0,1,2,3,4}; printf("PARENT: %d ",nums[i]); /* LINE Y */
int main() { }
int i; return 0;
pid_t pid; }
pid = fork();
if (pid == 0) {
for (i = 0; i < SIZE; i++) {
3. Consider the snapshot at time t in a Uniprocessor system. The I/O bound processes are represented as
xPy which means Process P goes for x units of I/O operation after every y units of execution.

Process Arrival Total Priority xPy


time Execution
time
A 0 3 4 2A2
B 2 5 2 -
C 3 2 0 -
D 5 4 1 2D2
E 9 5 3 -

a. Find the resultant schedule and represent it as Gantt chart using Preemptive Priority scheduling
algorithm. [5M]

b. Find normalized turnaround c. Find waiting period of process d. Mention the time(s) at which
time of process D. B. preemption(s) occur.
[2M] [2M] [1M]

You might also like