CSE316 Assignment Questions
CSE316 Assignment Questions
Roll No. Question No. Roll No. Question No. Roll No. Question No.
1 1 22 4 43 7
2 2 23 5 44 8
3 3 24 6 45 9
4 4 25 7 46 1
5 5 26 8 47 2
6 6 27 9 48 3
7 7 28 1 49 4
8 8 29 2 50 5
9 9 30 3 51 6
10 1 31 4 52 7
11 2 32 5 53 8
12 3 33 6 54 9
13 4 34 7 55 1
14 5 35 8 56 2
15 6 36 9 57 3
16 7 37 1 58 4
17 8 38 2 59 5
18 9 39 3 61 6
19 1 40 4 62 7
20 2 41 5 63 8
21 3 42 6 64 9
65 1 66 2 67 3
68 4 69 5 70 6
Questions
Q1. There are 3 student processes and 1 teacher process. Students are supposed to do their
assignments and they need 3 things for that-pen, paper and question paper. The teacher has an
infinite supply of all the three things. One student has pen, another has paper and another has
question paper. The teacher places two things on a shared table and the student having the
third complementary thing makes the assignment and tells the teacher on completion. The
teacher then places another two things out of the three and again the student having the third
thing makes the assignment and tells the teacher on completion. This cycle continues. WAP
to synchronise the teacher and the students.
• Two types of people can enter into a library- students and teachers. After entering the
library, the visitor searches for the required books and gets them. In order to get
them issued, he goes to the single CPU which is there to process the issuing of
books. Two types of queues are there at the counter-one for students and one for
teachers. A student goes and stands at the tail of the queue for students and
similarly the teacher goes and stands at the tail of the queue for teachers (FIFO). If
a student is being serviced and a teacher arrives at the counter, he would be the next
person to get service (PRIORITY-non preemptive). If two teachers arrive at the
same time, they will stand in their queue to get service (FIFO). WAP to ensure that
the system works in a non-chaotic manner.
• If a teacher is being served and during the period when he is being served, another
teacher comes, then that teacher would get the service next. This process might
continue leading to increase in waiting time of students. Ensure in your program
that the waiting time of students is minimized.
Q2. Consider a scheduling approach which is non pre-emptive similar to shortest job next in
nature. The priority of each job is dependent on its estimated run time, and also the amount of
time it has spent waiting. Jobs gain higher priority the longer they wait, which prevents
indefinite postponement. The jobs that have spent a long time waiting compete against those
estimated to have short run times. The priority can be computed as :
Priority = 1+ Waiting time / Estimated run time
Write a program to implement such an algorithm. Ensure
1. The input is given dynamically at run time by the user
2. The priority of each process is visible after each unit of time
3. The gantt chart is shown as an output
4. Calculate individual waiting time and average waiting time
Q3. Write a multithreaded program that implements the banker's algorithm. Create n threads
that request and release resources from the bank. The banker will grant the request only if it
leaves the system in a safe state. It is important that shared data be safe from concurrent
access. To ensure safe access to shared data, you can use mutex locks.
Ensure:
1. The program should be dynamic such that the threads are created at run time based on
the input from the user.
2. The resources must be displaced after each allocation.
3. The system state should be visible after each allocation
Q5. Sudesh Sharma is a Linux expert who wants to have an online system where he can
handle student queries. Since there can be multiple requests at any time he wishes to dedicate
a fixed amount of time to every request so that everyone gets a fair share of his time. He will
log into the system from 10am to 12am only. He wants to have separate requests queues for
students and faculty. Implement a strategy for the same. The summary at the end of the
session should include the total time he spent on handling queries and average query time.
Q6. Write a program for multilevel queue scheduling algorithm. There must be three queues
generated. There must be specific range of priority associated with every queue. Now prompt
the user to enter number of processes along with their priority and burst time. Each process
must occupy the respective queue with specific priority range according to its priority. Apply
Round Robin algorithm with quantum time 4 on queue with highest priority range. Apply
priority scheduling algorithm on the queue with medium range of priority and First come first
serve algorithm on the queue with lowest range of priority. Each and every queue should get
a quantum time of 10 seconds. CPU will keep on shifting between queues after every 10
seconds.
Q7. You are a computer systems engineer working at a large technology company. Your
manager has tasked you with creating a simulation program to test the performance of the
Round Robin scheduling algorithm. The simulation program should generate a set of
"processes" with random arrival times and CPU burst times, and should run the Round Robin
algorithm for a set amount of time (e.g. 100 time units). The program should record the
average waiting time and turnaround time for each process, and should compare the results
with the ideal scenario of a perfect scheduler.
Your manager is interested in the results of the simulation to evaluate how well the
Round Robin algorithm would perform in a real-world scenario, and to identify any
potential issues that need to be addressed. She has given you one week to complete
the simulation and to prepare a report of your findings and conclusions.
Problem: Create a simulation program that simulates a file system for the company.
The program should include a file system manager that uses a specific file allocation
algorithm (e.g. Contiguous Allocation or Linked Allocation) to allocate space for files
on a simulated disk. The students should also include a mechanism for deleting,
renaming and moving files. The simulation should run for a set amount of time and
record the average amount of fragmentation and the number of wasted disk blocks at
the end of each time unit.
The students should also consider the following factors in their simulation:
• The employees will be creating and editing different types of files (e.g.
documents, spreadsheets, images) with varying file sizes.
• The employees will be frequently adding and deleting files.
• The company wants to minimize the amount of wasted disk space.
At the end of the simulation, the students should provide a report on their findings and
observations, including the performance of the file system under different scenarios
and the trade-offs involved in the different file allocation algorithms.
Expected outcomes:
1. File allocation: The program should demonstrate the ability to allocate
space for files on a simulated disk using the chosen file allocation
algorithm (e.g. Contiguous Allocation or Linked Allocation).
2. File deletion and renaming: The program should include a mechanism for
deleting and renaming files.
3. Disk fragmentation: The program should record the average amount of
fragmentation at the end of each time unit. Fragmentation occurs when
there are small, unused blocks of disk space scattered throughout the disk
space.
4. Wasted disk space: The program should also record the number of wasted
disk blocks at the end of each time unit. Wasted disk space refers to blocks
of disk space that are no longer being used by any files.
5. Simulation results: The program should run the simulation for a set
amount of time and display the results, including the average amount of
fragmentation and the number of wasted disk blocks, at the end of each
time unit. The students should also experiment with different input
scenarios and algorithms to compare the results and see how different
factors affect the performance of the file system.