You are on page 1of 9

LOVELY PROFESSIONAL UNIVERSITY

Academic task- 3

School of Computer Science and Engineering Faculty of Technology And


Sciences

Name of the faculty member _Praveen Kaur

Course Code: CSE 316 Course Title: Operating Systems Term: 16172

Max. Marks:30 Date of Allotment:12/02/2017 Date of Submission: 19/04/2017

Important Points

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
orbefore the last date on UMS only. 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
stagethat the student has used unfair means like copying from peers or copy pasting the
code taken frominternet etc. ZERO marks will be awarded to the student.
6.The student who shares his assignment with other students (either in same section or
differentsection) will also get ZERO marks.
---------------------------------------------------------------------------------------------------

QUESTIONS

1. 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. Write a program to synchronize the teacher and the students.

2. Consider a scenario in which the scheduler allocates the CPU to processes in the ready
queue for a time slice of up to t milliseconds. If a process is not able to complete its
execution in t ms, it is interrupted and the scheduler proceeds to the next process in the
ready queue. The ready queue is to be treated as a circular queue. Assume that all the
processes arrived at time zero. Simulate this scenario by writing a program. The number
of processes, their burst time and time slice are to be taken as input from the user..

3. Design a scheduler that uses non-preemptive scheduling approach to schedule the


processes that have different arrival times. The burst time of a process is double its arrival
time. The process in the ready queue that has the largest burst time is assigned the CPU
first. Compute the average waiting time and average turnaround time. Input the data from
the user.

4. Consider a system consisting of p processes which arrive at different times. The process
that comes first is served first in a non-preemptive manner and preempt each process after
every 2 seconds. After that, the next arrived process is served by the CPU and this cycle
continues. Take the number of processes, burst times and arrival times as input from the
user and write a program to implement this type of scheduling.

5. Consider a scenario in which there are four page frames and eight pages. The frames are
initially empty. Write a program to find out the number of page faults if FIFO page
replacement is used. Take reference string as 0172327103.

6. Five processes A through E arrive in the system at almost the same time. They have
estimated running times of 10, 6, 2, 4 and 8 minutes. Their priorities are 3, 5, 2, 1 and 4
respectively, with 5 being the highest priority. Write a program to find out the mean
process turnaround time for – (a) priority scheduling and (b) FCFS scheduling.

7. Program a simulation of the banker’s algorithm. Your program should cycle through each
of the bank clients asking for a request and evaluating whether it is safe or unsafe. Output
a log of requests and decisions to a file.

8. Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently
serving a request at cylinder 143, and the previous request was at cylinder 125. The
queue of pending requests, in FIFO order, is 86, 1470, 913, 1774, 948, 1509, 1022, 1750,
130. Write a program to calculate the total distance (in cylinders) that the disk arm moves
to satisfy all the pending requests starting from the current head position for FCFS disk-
scheduling algorithm.

9. A uniprocessor system has n number of CPU intensive processes, each process has its
own requirement of CPU burst. The process with lowest CPU burst is given the highest
priority. A late-arriving higher priority process can preempt a currently running process
with lower priority. Simulate a scheduler that is scheduling the processes in such a way
that a higher priority process is never starved due to the execution of low priority
processes. What should be the average waiting time and average turnaround time if no
two processes are arriving at same time?
10. Write a program that detects if there is a deadlock in the system by using a resource
allocation graph. Your program should read from a file the following inputs: the number
of processes and the number of resources. For each process, it should read four numbers:
the number of resources it is currently holding, the IDs of resources it is holding, the
number of resources it is currently requesting, the IDs of resources it is requesting. The
output of your program should indicate if there is a deadlock in the system or not. In case
there is a deadlock in the system, the program should print out the identities of all
processes that are deadlocked.

11. Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently
serving a request at cylinder 143, and the previous request was at cylinder 125. The
queue of pending requests, in FIFO order, is 86, 1470, 913, 1774, 948, 1509, 1022, 1750,
130. Write a program to calculate the total distance (in cylinders) that the disk arm moves
to satisfy all the pending requests starting from the current head position for SSTF disk-
scheduling algorithm.

12. Write a program to implement priority scheduling algorithm with context switch time.
Prompt the user to enter the number of processes, their priority, burst time and arrival
time. Whenever a process is preempted and CPU's control is given to some other process
of higher priority, assume that it takes 2 seconds for context switching (dispatcher
latency). Simulate a scenario where the processes are assigned priority and a lower
priority number means higher priority. The priority of the waiting process increases at the
rate of 1 per 2 time units of wait. Calculate waiting time and turnaround time for each
process.

13. Design a scheduling program that is capable of scheduling processes that arrive in the
system at some time interval and are allocated the CPU for not more than 10 time units.
CPU must schedule processes having short execution time first. CPU is idle for first 3
time units and does not entertain any process prior to this time. Scheduler must maintain
a queue that keeps the order of execution of all the processes. Compute average waiting
and turnaround time.

14. There are 5 processes and 3 resource types, resource A with 10 instances, B with 5
instances and C with 7 instances. Consider the following and write a program to find out
whether the system is in safe state or not.

Available Processes Allocation Max


A B C A B C A B C
3 3 2 P0 0 1 0 7 5 3
P1 2 0 0 3 2 2
P2 3 0 2 9 0 2
P3 2 1 1 2 2 2
P4 0 0 2 4 3 3
15. Develop a scheduler which submits the processes to the processor in the following
scenario, and compute the scheduler performance by providing the waiting time for
process, turnaround time for process and average waiting time and turnaround
time.Considering the arrival time and the burst time requirement of the processes the
scheduler schedules the processes by interrupting the processor after every 3 units of time
and does consider the completion of the process in this iteration. The schedulers than
checks for the number of processes waiting for the processor and allots the processor to
the process but interrupting the processor after every 6 units of time and considers the
completion of the process in this iteration. The scheduler after the second iteration checks
for the number of processes waiting for the processor and now provides the processor to
the process with the least time requirement to go in the terminated state.
The inputs for the number of requirements, arrival time and burst time should be
provided by the user.

Consider the following units for reference.


Process Arrival time Burst time
P1 0 18
P2 2 23
P3 4 13
P4 13 10
16. Considering the arrival time and burst time requirement of the process the scheduler
schedules the processes by interrupting the processor after every 6 units of time and does
consider the completion of the process in this iteration. The scheduler than checks for the
number of process waiting for the processor and allots the processor to the process but
interrupting the processor every 10 unit of time and considers the completion of the
processes in this iteration. The scheduler checks the number of processes waiting in the
queue for the processor after the second iteration and gives the processor to the process
which needs more time to complete than the other processes to go in the terminated state.
The inputs for the number of requirements, arrival time and burst time should be
provided by the user.
Consider the following units for reference.
Process Arrival time Burst time
P1 0 20
P2 5 36
P3 13 19
P4 26 42

17. Consider a scheduler which schedules the job by considering the arrival time of the
processes where arrival time if given as 0 is discarded or displayed as error. The
scheduler implements the shortest job first scheduling policy, but checks the queue of the
processes after the every process terminates and time taken for checking and arranging
the process according to the shortest job is 2 time unit. Compute the waiting time,
turnaround time and average waiting time and turnaround time of the processes. Also
compute the total time taken by the processor to compute all the jobs.
The inputs for the number of requirements, arrival time and burst time should be
provided by the user.
Consider the following units for reference.
Process Arrival time Burst Time
1 0 6
2 3 2
3 5 1
4 9 7
5 10 5
6 12 3
7 14 4
8 16 5
9 17 7
10 19 2

18. 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.

19. Design a scheduler with multilevel queue having two queues which will schedule the
processes on the basis of pre-emptive shortest remaining processing time first algorithm
(SROT) followed by a scheduling in which each process will get 2 units of time to
execute. Also note that queue 1 has higher priority than queue 2. Consider the following
set of processes (for reference)with their arrival times and the CPU burst times in
milliseconds.
-------------------------------------
Process Arrival-Time Burst-Time
-------------------------------------
P1 0 5
P2 1 3
P3 2 3
P4 4 1
-------------------------------------
Calculate the average turnaround time and average waiting time for each process. The input for
number of processes and their arrival time, burst time should be given by the user.

20. Reena’s operating system uses an algorithm for deadlock avoidance to manage the
allocation of resources say three namely A, B, and C to three processes P0, P1, and P2.
Consider the following scenario as reference .user must enter the current state of system
as given in this example :
Suppose P0 has 0,0,1 instances , P1 is having 3,2,0 instances and P2 occupies 2,1,1
instances of A,B,C resource respectively.
Also the maximum number of instances required for P0 is 8,4,3 and for p1 is 6,2,0 and
finally for P2 there are 3,3,3 instances of resources A,B,C respectively. There are 3 instances
of resource A, 2 instances of resource B and 2 instances of resource C available. Write a
program to check whether Reena’s operating system is in a safe state or not in the following
independent requests for additional resources in the current state:
1. Request1: P0 requests 0 instances of A and 0 instances of B and 2 instances of C.
2. Request2: P1 requests for 2 instances of A, 0 instances of B and 0 instances of C.
All the request must be given by user as input.
21. A barbershop consists of a waiting roomwith n chairs and a barber room with one barber
chair. If there are no customers to be served, the barber goes to sleep. If a customer
entersthe barbershop and all chairs are occupied, then the customer leaves theshop. If the
barber is busy but chairs are available, then the customer sitsin one of the free chairs. If
the barber is asleep, the customer wakes upthe barber. Write a program to coordinate the
barber and the customers.Using synchronization tools like locks, semaphores and
monitorsprovide a solution to his problem.

22. 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.

RegisterationNumber Name RollNumber Q.No.


11503255 Aashish Jain RK1514A01 15
11504734 Shiv Kishan Rawat RK1514A02 11
11504441 Mahesh Kumar Prajapat RK1514A03 22
11509938 Ravinder RK1514A04 1
11506366 Aashish Gupta RK1514A06 12
11505111 Prabhsimran Singh Walia RK1514A07 21
11509914 Nritam Kumar RK1514A08 2
11505553 Lasic Goel RK1514A09 9
11509984 Pranjul RK1514A10 13
11508240 Himanshu Sharma RK1514A11 20
11502237 Lokendra Singh RK1514A12 3
11505703 Apurva Roshan RK1514A13 19
11501353 Satyam Singh Panwar RK1514A14 14
11506932 Abhishek Sharma RK1514A15 4
11510006 Prarthona Saikia RK1514A16 18
11510801 Sahil Mall RK1514A17 8
11507611 Valisetty Naveen Kumar RK1514A18 15
11505210 Tanmay Thaware RK1514A19 7
11505001 Anurag Tiwari RK1514A20 5
11501754 Nihal Sarawgi RK1514A21 17
11505592 Akshay Srivastava RK1514A22 6
11505600 Datta Shreyash Sanjay RK1514A23 16
11502547 Ashish Kumar Shakya RK1514A24 5
11511254 Balraj Singh RK1514A25 10
11511442 Ankit Kumar RK1514A26 12
11303994 Hari Om RK1514A54 21
11504656 Abhishek Sharma RK1514A54 4
11505710 Kancharla Kalyan Prasad RK1514A55 22
11509983 Nagendra Pratap Singh RK1514B28 11
11502307 Sofia RK1514B29 20
11506402 Sekh Abeer RK1514B30 5
11505293 Ankit Gangwar RK1514B31 8
11509791 Shilpa Kumari RK1514B32 19
11500954 Swetha R RK1514B33 12
11503247 Sanjay Kumar Yadav RK1514B34 7
11507605 Nathani Sai Kiran RK1514B35 13
11505239 Nupur RK1514B36 18
11502406 Abhilash Bagde RK1514B37 6
11506899 Shubham Goyal RK1514B38 14
Perumalla Murali Mallikarjuna
11501280 Rao RK1514B39 7
11507936 Vatsal Gupta RK1514B40 17
11506676 Payal Kumari RK1514B41 9
11511262 Abhishek Singh RK1514B42 1
11500956 Swathy R RK1514B43 15
11508283 Prashant Gupta RK1514B44 16
11502096 Mimanshu Singh RK1514B46 3
11508128 Yogita RK1514B48 22
11511595 Ajit Kumar Dev RK1514B49 2
11505558 Aditya Kumar RK1514B50 10
11505292 Priyesh RK1514B51 21
11505696 Madhava Kuzhalone R RK1514B52 11
11506571 Shubham Dubey RK1514B53 20
11404892 Devesh Kumar Sharma RK1514B56 12
11501414 Marpu Vinod RK1514B57 19

---------------------------------------------------------------------------------------------------

You might also like