Name:
Enrolment No:
Odd Semester End Term Examination, May 2025
Faculty of Science, Technology and Architecture, School of Computer Science and Engineering
Department Computer Science and Engineering
B. Tech CSE
Course Code: CSE2202 Course: Operating Systems Semester: 4th
Time: 03 hrs. Max. Marks: 80
Instructions: All questions are compulsory.
Missing data, if any, may be assumed suitably.
Calculator is allowed.
SECTION A
[Link]. Marks CO
Define User Mode and Kernel Mode in the context of an operating system. Why is it necessary
Q1 CO1
to have these two separate modes of operation?
Q2 Write syntax and explain the usage of pthread_create() and pthread_join(). CO2
Q3 Why is aging used during priority scheduling algorithms? CO3
5*2=10
Using the FIFO page replacement policy and assuming 3-page frames, how many page faults
Q4 would occur for the page reference string ‘ABCABDDCABCD’? Show the state of the memory CO4
frames after each page reference
Q5 What is pipe() system call in UNIX. What are the file descriptors returned by it? CO2
SECTION B
Consider a system with four resource types: A, B, C D, and five processes: P0, P1, P2, P3, and
P4. The system is in a particular state, with the following resource allocation and maximum
resource requirements:
Process Allocation Max Available
A B C D A B C D A B C D
P0 0 0 4 5 0 0 4 5 4 8 5 0
Q6 P1 3 0 0 0 4 10 8 0 2+4+4 CO3
P2 3 6 8 7 5 6 8 9
P3 0 9 6 5 0 9 8 5
P4 0 0 4 7 0 9 8 9
i. Write down the Banker’s Algorithm.
ii. Determine whether the system is in a safe state using the Banker’s Algorithm.
iii. If request from P1 arrives for (0, 4, 2, 0), can it be granted immediately?
i. What is paging? How does it overcome the drawbacks of dynamic partition method of
contiguous allocation? Justify your answer.
ii. Suppose we have a computer system with a 44-bit virtual address, page size of 64K, and
Q7 4 bytes per page table entry. 3+2+2+3 CO4
a. How many pages are in the virtual address space?
b. Suppose we use two-level paging and arrange for all page tables to fit into a single
page frame. How will the bits of the addresses be divided up?
c. Suppose we have a 4GB program such that the entire program and all necessary
page tables are in memory. How much memory (in page frames) is used by the
program, including its page tables?
Alice, Ben, and Charlie are working together in a tree plantation task:
a. Alice digs holes in the ground.
b. Ben plants saplings in the holes.
c. Charlie fills the holes with soil after planting.
They must follow these rules:
A. Ben can only plant a sapling if Alice has already dug a hole, and it’s still empty.
Q8 B. Charlie can only fill a hole if Ben has already planted a sapling in it, but it hasn’t been 4+3+3 CO3
filled yet.
C. Alice must wait if the number of dug but unfilled holes reach MAX, so she doesn’t dig
too far ahead.
D. Alice and Charlie share one shovel, so only one of them can dig or fill at a time.
Write pseudocode for the three workers — Alice, Ben, and Charlie — using semaphores for
synchronization. Also, initialize all semaphores before use.
SECTION-C
i. A computer system uses segmentation with paging. The page size is 1 KB. A segment
table entry has the following fields:
• Base address of the page table: 4000
• Segment limit: 5 pages
Given a logical address with
• Segment number = 2
Q9 • Page number within the segment = 3 4+4 CO4
• Offset within the page = 200 bytes,
Calculate the physical address assuming the page frame number for segment 2, page 3
is 150.
ii. Consider a system where a memory reference takes 100ns, if we add TLB and 95% of
the page table reference are found in the TLB. What is effective memory access time
with TLB assume TLB access time is 20 ns .
Write a C program that opens a file. After opening the file, the program should create a child
process. The parent process should write the string "Hello Child" into the file. Meanwhile, the
child process must wait until the parent has completed writing the file. After the parent finishes,
the child process should read the contents of the file and display them on the console. Ensure
correct synchronization between the parent and child processes .Use appropriate semaphore and CO2
Q 10 6+6
system calls like open(), write(), read(), and close() etc.
Finally, briefly explain why synchronization between the parent and child is necessary Also,
discuss what issues may arise in the child process if synchronization is not properly
implemented.
SECTION-D
Q 11 A file system uses 512-byte physical blocks. Each file has a directory entry containing the file
name, the location of the first block, the total length of the file, and the last block position
10 CO5
accessed. Assume the directory entry and the last block read are already in main memory. For
the following scenarios, determine how many physical blocks must be read to access the target
block (including the reading of the target block) using each of the following allocation
techniques: contiguous, linked, and indexed.
i. Last block read: 250; block to be read: 700
ii. Last block read: 750; block to be read: 300
iii. Last block read: 45; block to be read: 46
iv. Last block read: 46; block to be read: 45
Q 12 The disk queue in front of a disk head is as follows (in order): 70, 25, 150, 175, 85, 60, 120, 30
The disk head starts at position 95.
Perform and show the order of servicing the requests using the following disk scheduling
algorithms:
i. Shortest Seek Time First (SSTF)
ii. SCAN (Assume the head moves towards the higher cylinder numbers first.)
5+5 CO5
iii. C-SCAN (Assume the head moves towards the Lower cylinder numbers first.)
iv. C-LOOK (Assume the head moves towards the higher cylinder numbers first.)
For each algorithm:
a. Show the sequence of requests serviced with neat diagram.
b. Calculate the Seek time (in number of cylinders).
Assume the disk with 200 cylinder numbered from 0 to 199.