CE-303 Operating Systems Final Spring 2021
CE-303 Operating Systems Final Spring 2021
IMPORTANT INSTRUCTIONS:
You must follow general guideline for students before online examination and during online
examination which had already shared by email and WhatsApp.
SSUET Page 1 of 3
Online End Semester Examinations: Spring 2021
(a) Given the following stream of page references by an application, compare the performance of
the algorithms by calculating the number of page faults the application would incur with the
FIFO, LRU and Optimal page replacement algorithms. Assume that there are 3 frames, and all
are initially empty. (05 Marks)
Reference Stream: F E G B X1 D E G A X1 F B E X1 H E B G
(Where X1 is the first vowel of your name, e.g. ‘X1’=O if your name is OSAMA AHMED
(b) Analyze the given paging system with the page table stored in memory and answer the following:
i. If a memory reference takes 50 nanoseconds, how long does a paged memory reference take?
ii. If we add TLBs, and Y percent of all page-table references are found in the TLBs, identify
the effective memory reference time. Assume that finding a page-table entry in the TLBs takes
2 nanoseconds, if the entry is present. (05 Marks)
(Where Y=100-(3 digit roll number), if your roll number is 2019-CE-030, then Y=100-30=70)
(b) Given a disk with 250 tracks, where track requests are received in the following order 55, 58,
39, 18, 90, Y, 160, 150, 38, 184. The starting position for the arm is track 30 and previously it
was on track 25. Estimate the total number of tracks crossed when the following algorithms are
used: FCFS, SSTF, C-SCAN and LOOK. (05 Marks)
(Use Y=50+(Z*11), where Z=0+2+5=7, for roll number 025, means Y=50+(7*11)=127
(b) Compare the methods used by processes P1 and P2 for accessing their critical sections whenever
needed, as given below. The initial values of shared Boolean variables S1 and S2 are randomly
assigned.
Method Used by P1 Method Used by P2
while (S1 == S2) ; while (S1 != S2) ;
Critica1 Section Critica1 Section
S1 = S2; S2 = not (S1);
SSUET Page 2 of 3
Online End Semester Examinations: Spring 2021
(b) Suppose the following snapshot of the system has five processes (P1, P2, P3, P4 and P5)
and four types of resources (A, B, C and D). There are multiple resources of each type. Is
the following state safe or not? Calculate the Need matrix and estimate the sequence in
which processes can complete execution. If not, show how deadlock may occur.
(05 Marks)
int main () {
int n, status;
pid_t child;
n = 0;
if (!(child = fork())) {
n = 1;
fprintf (stderr, "n = %d\n", n);
n = 2;
} else {
n = 3;
fprintf (stderr, "n = %d\n", n);
n = 4;
exit (0);
fprintf (stderr, "n = %d\n", n);
}
waitpid (child, &status, 0);
n = 5;
fprintf (stderr, "n = %d\n", n);
return 0;
}
(b) With the help of appropriate programming examples and system calls, demonstrate how Inter-
process Communication is performed using pipe() in Linux Operating System. (05 Marks)
(Your answer should not be copied from other students. It will result in 0 marks)
(END)
SSUET Page 3 of 3