0% found this document useful (0 votes)
61 views3 pages

Quiz 1 Questions

The document is an open book quiz for an Operating Systems course. It contains 3 questions. The first asks how many unique processes and threads are created from the given code segment. The second asks to explain the output of two print statements in a provided code segment using fork. The third asks to draw a Gantt chart showing the schedule under preemptive priority scheduling for the given processes, and calculate additional metrics like turnaround time and waiting time for specific processes.

Uploaded by

nasa stick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views3 pages

Quiz 1 Questions

The document is an open book quiz for an Operating Systems course. It contains 3 questions. The first asks how many unique processes and threads are created from the given code segment. The second asks to explain the output of two print statements in a provided code segment using fork. The third asks to draw a Gantt chart showing the schedule under preemptive priority scheduling for the given processes, and calculate additional metrics like turnaround time and waiting time for specific processes.

Uploaded by

nasa stick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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