0% found this document useful (0 votes)
81 views13 pages

B I T & S, P - K. K. B G C: Irla Nstitute of Echnology Cience Ilani Irla OA Ampus

The document provides details about an operating systems exam including questions about multi-programming, distributed systems memory models, microkernel architecture, semaphores, process states, thread cancellation, process IDs, memory allocation using buddy system, page table hierarchy, scheduling algorithms, and process scheduling. The exam asks students to determine if statements are true or false and justify their answers. It also asks students to provide sequences of events, describe concepts in one sentence, draw representations of memory allocation, and calculate timing details for memory access and scheduling.

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)
81 views13 pages

B I T & S, P - K. K. B G C: Irla Nstitute of Echnology Cience Ilani Irla OA Ampus

The document provides details about an operating systems exam including questions about multi-programming, distributed systems memory models, microkernel architecture, semaphores, process states, thread cancellation, process IDs, memory allocation using buddy system, page table hierarchy, scheduling algorithms, and process scheduling. The exam asks students to determine if statements are true or false and justify their answers. It also asks students to provide sequences of events, describe concepts in one sentence, draw representations of memory allocation, and calculate timing details for memory access and scheduling.

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/ 13

BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI – K. K.

BIRLA GOA CAMPUS


First Semester 2019-2020
Course Title: OPERATING SYSTEMS Course No CS F372 Weightage: 35%[105 Marks]
Component: Comprehensive Examination [Closed Book] Date: 09/12/2019 Max.Time: 180min
Question #1 [6 Marks]
A system without DMA will not be able to implement multi-programming.
TRUE/FALSE? Justify.
[0/2 Marks] TRUE. Disk I/O of a process can execute in
parallel with CPU of another process only if DMA takes
care of Disk I/O

NORMA is the most widely used memory model for distributed systems.
TRUE/FALSE? Justify.
[0/2 Marks] TRUE. Absence of shared memory in
distributed system makes sharing possible only through
message passing through the other processor. This is
done with NORMA

Write one merit and one demerit of Micro kernel architecture over monolithic
kernel architecture
[1Marks] Merit: Easier to expand, Easier to port to a new
architecture, More reliable, More secure [one of these]
[1 Marks] Demerit: Performance overhead of user space to
kernel space communication
Question #2 Write in back side of this sheet [6 Marks]
Assume 50 concurrently running threads [Thread 1 to Thread 50] are created by
using the fun1 function. The argument passed to the thread is (-1* thread
number). i.e., Thread 1 will get arg as -1 and thread 50 will get arg as -50. If there
exist race condition because of the shared variable x with initial value as 0
[context switching can happen anywhere in the program],
Find the following,
void *fun1(int *arg)
(A) What is the largest possible value of x under
{ int j;
race condition? Show the sequence of execution
x = *arg;
which will give the largest possible value of x.
for (j = 0; j<100; j++)
(B) If possible give a sequence, as simple as possible
x = x – 1;
such that the value of x is –5025 after the
pthread_exit(0);
successful execution of all 50 threads.
}
If not possible explain concisely.

(A) [0/1/4 Marks]


[1 Mark] -2
[3 Marks] Sequence:
All threads except Thread 1 and one other thread (say
thread 2) finishes.
Thread 2 finished 99 times execution of x-1. Then thread
1 executes x=arg. This makes x=-1. Context switches to
thread 2 which executes Reg1x. Context switches to
thread 1 and finishes thread 1 completely. Thread 2
continues its last x-1. Resultant x = -2.

(B) [0/2 Marks]


All threads except 25th thread finishes x=arg followed by
25th thread. X=-25. Threads execute for loop one after
the other. -25 + (50*100*-1) = -25 + -5000 = -5025
Question #3 [6 Marks]
Describe a situation where a counting semaphore wait and signal behaves
differently than a condition variable wait and signal.
[0/1.5 Marks] Condition variable signal does
nothing if no thread is waiting on it whereas
semaphore wait will increment its value by 1.
[0/1.5 Marks] Condition variable suspends the
thread when it execute wait whereas semaphore
wait will suspend a thread only if its value is 0 or
less.
What TASK_NOLOAD state of a process represent? What is its relation with
TASK_IDLE?
[0/2 Marks] TASK_NOLOAD: state of the IDLE
process when no ready to run tasks are available in
system.

[0/1 Marks] TASK_IDLE: TASK_UNINTERRUPTIBLE


| TASK_NOLOAD
Question #4 Write in back side of this sheet [10 Marks]
Consider the following snap shot of the system at T0 consisting of five processes
P0 to P4 and 5 resource types A, B, C, D, and E. The total instances of A, B, C, D,
and E in the system are 14, 18, 17, 15 and 16 respectively
Process Maximum Claim Need
A B C D E A B C D E
P0 8 6 6 4 7 5 4 3 1 6
P1 10 6 8 7 13 6 4 7 3 10
P2 2 7 5 7 4 2 2 1 5 1
P3 4 2 5 3 2 4 0 2 0 1
P4 9 13 15 11 12 7 10 12 10 8
(A) Determine whether the system is in safe state or not. If yes, give safe
sequence.
(B) At time T0, if the process P1 request (0, X, 1, Y, Z), then determine the
maximum value of X, Y and Z which can be granted without making the state
unsafe.
(C) At time T0, P4 is requesting (0,2,1,0,3) and this request was granted.
Determine if the system is in safe state and give the safe sequence if any;
otherwise list the processes in unsafe state [Answer as continuation of PART
A. Assume the request in PART B is non-existent].

(A) [1.5 Marks] [Safe Sequence] <P3, P2, P0, P4, P1>

(B) [4.5 Marks – 1.5 each] X = 3, Y = 0, Z = 1

(C) [0/1/4 Marks]Not possible. <P0, P4 and P1> will not be


able to proceed.
Question #5 [8 Marks]
What all process states form TASK_NORMAL? [Max. One Sentence]
[2 Marks] TASK_INTERRUPTIBLE |
TASK_UNINTERRUPTIBLE
How is thread cancellation on Linux systems managed? [Max. One Sentence]
[2 Marks] Handled through signals / Deferred
(periodical) cancellation

Child process always get higher PID than the parent. TRUE/FALSE. Justify.
[0/2 Marks] FALSE. The pid allocation checks the
first free slot from the last allocated pid. If max pid
reaches it continues it search from 2 which may
result in child getting a lower pid number than
parent
When fork system call is issued, the PF_FORKNOEXEC flag is cleared.
TRUE/FALSE? Justify.
[0/2 Marks] FALSE. The flag is set to make sure
exec calls by default is not executed
Question #6 Write in back side of this sheet [8 Marks]
Assume a memory management module supporting BUDDY system for the
placement of 1 MB memory. Allocate the following requests [the requests are
coming one after the other in the same order]. Clearly mention all the requests
which you could not allocate.
Request 1: Allocate 70KB Request 7: Allocate 300KB
Request 2: Allocate 14KB Request 8: Allocate 46KB
Request 3: Allocate 100KB Request 9: Allocate 62KB
Request 4: Allocate 140KB Request10: Release 100KB [Allocated by request 3]
Request 5: Allocate 190KB Request11: Allocate 180KB
Request 6: Release 140KB [Allocated by request 4]
After finishing all the requests
(A) Draw the final tree representation of the BUDDY system.

1MB

512KB
512KB

256KB

R11 R5 256KB
256KB

128KB

128KB R1 128KB

64KB R8 R9 64KB

64KB
32KB
Request 7 could not be
32KB allocated. [0/1/3 /4]

16KB R2 16KB

(B) [2 Marks] Find the total free space available in the system for allocation
16KB + 32KB + 64KB + 128KB = 240KB
(C) [2 Marks] Find the total internal fragmentation caused because of all the
allocation: (128 - 70) + (16 - 14) + (256 – 190) + (64 - 46) + (64 - 62) + (256-
180) = 58+2+66+18+2+76=222KB
Question #7 [6 Marks]
A system with TLB and Main Memory support Segmentation with 3 level
hierarchical paging. Assume process P0 [the complete process and all the page
tables] is available in Main Memory. The process has to access memory 10000
times to complete its operations. While executing, 1500 accesses result in TLB
miss. TLB access time is 5nS and Main Memory access time is 200nS. Find the
total time taken for accessing memory by process P0.

[0/2 Marks] TLB hit Memory Access time


8500*(5nS+200nS) = 1742500
[0/4 Marks] TLB miss Memory Access time
1500*(5nS+600nS+5nS+200nS) = 1215000

Total = 2957500

Same as

10000*(5+200) + 1500*(5+600) =
2050000+907500 = 2957500
Question #8 Write in back side of this sheet [12 Marks]
A Linux OS supporting O(1) Scheduler has the following snapshot at time t.
Assume that the order of arrival of processes to the system is Process A to G.
Process Nice Execution Avg.Sleep RealTime Sched policy
Time(ms) time(ms) Priority
A 9 50 110 - SCHED_OTHER
B 10 80 350 - SCHED_OTHER
C -18 800 0 - SCHED_OTHER
D -12 1320 740 - SCHED_OTHER
E 0 200 220 10 SCHED_RR
F 5 150 310 10 SCHED_FCFS
G -1 450 720 12 SCHED_RR
(A) Find Static Priority for all the processes.
(A) to (C) write as a single table
(B) Find Quantum time for all the processes.
(C) Find Dynamic priority for all Conventional processes at time t.
(D) Find the resultant schedule and represent it as Gantt chart [Assume
execution of X units result in decrease of average sleep time of that process
by X/4 units] Note: Interactive Delta = (static priority/4)-28 End Note.

Process Nice Static Quantum Dynamic


Priority time Priority
A 9 129 55 133
B 10 130 50 132
C -18 102 760 107
D -12 108 640 106
E 0 120 100 X
F 5 125 75 X
G -1 119 420 X

(A) 2 Marks [4 values correct 1, 6 values correct 1.5, All values 2]


(B) 3 Marks [1 or 2 values correct 0.5, 3 values correct 1, 4 correct 1.5, 5
values correct 2, 6 values 2.5, 7 values 3]
(C) 2 Marks [0.5 *4]
(D) 5 Marks Schedule [1.5 till 800]
3.5 till 3050 [until first mistake]

C
F G D D
E E

0 100 250 350 800 1440 2200 2840

C
A D
B B

2840 2890 2940 2980 3020 3050


0
Question #9 [12 Marks]
Consider the following snapshot at time t in a Uniprocessor system. Process P
goes for x units of I/O operation after every y units of execution are represented
as xPy. [Assume all processes are finishing with CPU execution].
Process Arrival Total CPU Priority (lesser xPy
time Execution priority number
time higher priority)
A 0 10 3 1A6
B 1 10 1 7B5
C 2 8 2 3C3
D 8 6 0 3D2
Find the resultant schedule and represent it as Gantt chart if the scheduling
algorithm is:
(A) Virtual Round Robin where Quantum time is 6
(B) Shortest Remaining Time First [Answer backside of this sheet]
(C) Preemptive Priority Scheduling [Answer backside of this sheet]
Note:Tie break [if any] is using arrival time. Earlier arrived one gets selected

(A) [0 / 2 / 4 Marks]

(B) [0 / 2 / 4 Marks]

(C) [0 / 2 / 4 Marks]
Question #10 Answer in Main Sheet [10 Marks]
A, B and C are sharing a common kitchen [critical section] to prepare lunch every
day. To have lunch, each person has to prepare 3 items. Only one person can
own the kitchen at a time for preparing one item. The order of preparation is as
follows:
Main thread signals the food time. A prepares 2 items one after the other
[executes critical section twice] before giving a chance to B. B and C will alter
their execution [i.e. one item of B followed by one item of C] until B and C finishes
their lunch preparation. After C finishes its 3rd item, A will prepare its 3rd item.
This process repeats every meal time. Assume A, B and C are 3 concurrently
executing threads, solve the problem using semaphores. Create these 3 threads
from your Main thread. You are allowed to create only the semaphore variables
globally [initialize them in your Main thread]. You are allowed to use local
variables within any thread. Use only wait and signal operations to alter values of
semaphore variables after initialization. Implement the problem by using threads
and counting semaphores. Make sure you are using the POSIX and semaphore
functions for the same [pseudo code will not be evaluated!!!]
Note: You are not allowed to write more than one critical section inside a thread!!
#include<pthread.h>
#include<semaphore.h>
#include<stdio.h>
void *threadA(void *param);
void *threadB(void *param);
void *threadC(void *param);

sem_t semA, semB, semC;


int main(int argc,char *argv[])[2 Marks]
{
sem_init(&semA,0,0);
sem_init(&semB,0,0);
sem_init(&semC,0,0);
printf("In main thread\n");
pthread_t tidA, tidB, tidC;
pthread_create(&tidA,NULL,threadA,NULL);
pthread_create(&tidB,NULL,threadB,NULL);
pthread_create(&tidC,NULL,threadC,NULL);
printf("Threads successfully created by main thread\n");
printf("Starting the meal session\n");
while(1)
{
sem_post(&semA);
sleep(20);
}
pthread_join(tidA,NULL);
pthread_join(tidB,NULL);
pthread_join(tidC,NULL);
printf("All are done\n");

}
void *threadA ( void *param ) [3 Marks]
{
int x=0;
while(1)
{
sem_wait(&semA);
printf("thread A is using kitchen to prepare %d th
item\n",(x+1));
fflush(stdout);
x++;
if(x==1) sem_post(&semA);
else if(x==2) sem_post(&semB);
else x=0;
}
pthread_exit(0);
}

void *threadB ( void *param ) [2 Marks]


{
int y=0;
while(1)
{
sem_wait(&semB);
printf("thread B is using kitchen to prepare %d th
item\n",(y+1));
fflush(stdout);
y++;
sem_post(&semC);
if(y==3)
y=0;
}
pthread_exit(0);
}

void *threadC ( void *param ) [3 Marks]


{
int z=0;
while(1)
{
sem_wait(&semC);
printf("thread C is using kitchen to prepare %d th
item\n",(z+1));
fflush(stdout);
z++;
if(z==3)
{
z=0;
sem_post(&semA);
}
else
sem_post(&semB);
}
pthread_exit(0);
}
Question #11 [11 Marks]
A system with 34 bit physical address has 16KB page size. For a 3-level
hierarchical paging system, the outer most page table fits exactly into one page
when its one entry size is 8 bytes. The entry size doubles with each level from
outer to inner. All the page tables fit with page boundary.
(A) Find the number of bits in virtual address
(B) How will the bits of the virtual address be divided up?
(C) What will be the number of frames required to store the largest process’ page
table if the complete page table needs to be in memory?
(D) If the process is 16GB size, what will be the total number of frames required to
hold all its page tables in MM? (mention frames required at each level)

(A) 44 bits [1 Mark]

(B) Division [2 Marks]


11 bits 10 bits 9 bits 14 bits

(C) [4 Marks]
Largest process 2^44
1 frame for Outer most page table
[1.5 Marks] 2^11 frames for middle level page table
[1.5 Marks] 2^21 frames for inner most page table

(D) [4 Marks]
Process size: 16GB
[1 Mark] 1 frame for Outer most page table
[1.5 Marks] 2 frames for Middle level page table
[1.5 Marks] 2^11 frames for inner most level page table
Question #12 Answer in Main Sheet [10 Marks]
Consider a uni-processor system with 5 CPU bound processes [P0, P1, P2, P3 and
P4] with no I/O in ready to run state. Assume P0 and P1 belongs to Group 0, P2
and P3 belongs to Group 1 and P4 belong to Group 2. Base priorities of P0 to P4
are 47, 46, 48, 44 and 50 respectively. The group weightage of Group 0, Group 1
and Group 2 are 40%, 30% and 30% respectively. The execution times of P0 to P4
are 20, 80, 40, 80, and 60 units respectively. Assume decision is made after every
40 units or completion of a process. [If all the processes of a group finishes, the
group weightage is equally split into other groups]. Show the priority, CPU count
and Group count of all the continuing processes at each decision point and the
resultant Gantt chart when it is scheduled using Fair Share Scheduling.

G0 (40%) G1 (30%) G2 (30%)


P0 P1 P2 P3 P4
47 0 0 46 0 0 48 0 0 44 0 0 50 0 0

0 0 0 0 0 40 40 40 0 0
47 0 0 46 0 0 64 0 20 70 20 20 50 0 0

0 40 40 40 0 20 20 20 0 0
59 0 20 68 20 20 56 0 10 57 10 10 50 0 0

0 0 0 0 0 10 10 10 40 40
53 0 10 57 10 10 52 0 5 50 5 5 76 20 20

0 10 10 10 0 45 45 45 20 20
50 0 5 51 5 5 66 0 22 63 10 10

20 25 5 25 0 22 10 10
54 2 12 57 0 11 56 5 5

42 52 0 11 5 5
50 0 5 52 2 2

40 45 2 2
50 1 1

21 21
[1.5*3 + 1*3 + 0.5 = 8 Marks]

[2 Marks]
0 to 40 P3 40 to 80 P1
80 to 120 P4 120 to 160 P3*
160 to 180 P0* 180 to 220 P1*
220 to 260 P2* 260 to 280 P4*

You might also like