B I T & S, P - K. K. B G C: Irla Nstitute of Echnology Cience Ilani Irla OA Ampus
B I T & S, P - K. K. B G C: Irla Nstitute of Echnology Cience Ilani Irla OA Ampus
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) [1.5 Marks] [Safe Sequence] <P3, P2, P0, P4, P1>
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.
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.
C
F G D D
E E
C
A D
B B
(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);
}
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);
}
(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.
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*