0% found this document useful (0 votes)
33 views

CSE316 Assignment Questions

The document provides instructions for completing a compulsory assignment. It states that the assignment must be done individually and submitted online by the deadline to receive marks. Unfair practices like plagiarism will result in zero marks. The document includes a question allocation table that assigns each student a unique question number. It then lists 6 sample questions related to process scheduling algorithms. Students must write code to simulate the given scheduling problem, document their methodology, and include output screenshots in their report.

Uploaded by

Himanshu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

CSE316 Assignment Questions

The document provides instructions for completing a compulsory assignment. It states that the assignment must be done individually and submitted online by the deadline to receive marks. Unfair practices like plagiarism will result in zero marks. The document includes a question allocation table that assigns each student a unique question number. It then lists 6 sample questions related to process scheduling algorithms. Students must write code to simulate the given scheduling problem, document their methodology, and include output screenshots in their report.

Uploaded by

Himanshu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Instructions

1. This assignment is a compulsory CA component.


2. The assignment is to be done on individual basis (no groups)
3. The assignment submission mode is Online only. Student has to upload the
assignment on or before the last date on UMS or any other platform if notified. No
submission via e-mail or pen-drive or any media will be accepted.
4. Non-submission of assignment on UMS till the last date will result in ZERO marks.
5. The student is supposed to solve the assignment on his/her own. If it is discovered at
any stage that the student has used unfair means like copying from peers or copy
pasting the code taken from internet etc. ZERO marks will be awarded to the student.
6. The student who shares his assignment with other students (either in same section or
different section) will also get ZERO marks.
7. Prepare a report which contains:
a. The methodology adopted to solve the problem
b. Code
c. Output snapshots

Question Allotment Table

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

Q4. Design a scheduling program to implements a Queue with two levels:


Level 1 : Fixed priority preemptive Scheduling
Level 2 : Round Robin Scheduling
For a Fixed priority preemptive Scheduling (Queue 1), the Priority 0 is highest priority. If one
process P1 is scheduled and running, another process P2 with higher priority comes. The
New process (high priority) process P2 preempts currently running process P1 and process P1
will go to second level queue. Time for which process will strictly execute must be
considered in the multiples of 2.
All the processes in second level queue will complete their execution according to round
robin scheduling.
Consider: 1. Queue 2 will be processed after Queue 1 becomes empty.
2. Priority of Queue 2 has lower priority than in Queue 1.

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.

As a computer systems engineer, you will need to:

a. Design and implement the simulation program using a programming language


of your choice.
b. Generate a set of "processes" with random arrival times and CPU burst times
using a random number generator.
c. Implement the Round Robin scheduling algorithm in the simulation program.
d. Have the simulation program run for a set amount of time (e.g. 100 time units)
and record the average waiting time and turnaround time for each process.
e. Compare the results of the simulation with the ideal scenario of a perfect
scheduler.

Q8. Student to implement a simulation program that simulates a computer's memory


management system. The program should include a memory manager that uses a specific
memory allocation algorithm (e.g. First-Fit, Best-Fit, or Worst-Fit) to allocate blocks of
memory to processes. The students should also include a mechanism for deallocating
memory when a process completes. The simulation should run for a set amount of time and
record the average amount of fragmentation and the number of wasted memory blocks at the
end of each time unit. The below mentioned outcomes are expected:
1. Memory allocation: The program should demonstrate the ability to allocate
blocks of memory to processes using the chosen memory allocation algorithm
(e.g. First-Fit, Best-Fit, or Worst-Fit).
2. Memory deallocation: The program should include a mechanism for
deallocating memory when a process completes, such as a "garbage collector"
or a "free list."
3. 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 memory scattered throughout the memory space.
4. Wasted memory: The program should also record the number of wasted
memory blocks at the end of each time unit. Wasted memory refers to blocks
of memory that are no longer being used by any processes.
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 memory 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 memory manager.
Q9. Scenario: A company has a large number of employees who work on various projects
and create different types of files such as documents, spreadsheets, and images. The company
wants to implement a new file system that can manage the disk space efficiently and handle
the high volume of file operations.

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.

You might also like