Revised Assignment
Revised Assignment
2. Examine the given lines of code. How many numbers of Processes created?
#include <stdio.h>
#include <unistd.h>
int main()
{
int i;
for (i = 0; i < 4; i++)
fork();
return 0;
}
3. Many CPU-scheduling algorithms are parameterized. For example, the RR algorithm requires a
parameter to indicate the time slice. Multilevel feedback queues require parameters to define the
number of queues, the scheduling algorithms for each queue, the criteria used to move processes
between queues, and so on.
These algorithms are thus really sets of algorithms (for example, the set of RR algorithms for all time
slices, and so on). One set of algorithms may include another (for example, the FCFS algorithm is the
RR algorithm with an infinite time quantum). What (if any) relation holds between the following pairs
of algorithm sets?
a. Priority and SJF
b. Multilevel feedback queues and FCFS
c. Priority and FCFS
d. RR and SJF
4. Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0,
2 and 6, respectively. How many context switches are needed if the operating system implements a
shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and
at the end. [gate 2006]
5. You are an IT consultant working with a small business owner who is setting up a computer network
for their office. The business owner has specific requirements for the operating system, and your task
is to recommend the most suitable classification of operating system based on these requirements.
a) The business owner needs an operating system for their office desktop computers. They want an
OS that is user-friendly, supports common office software, and is cost-effective. What classification
of operating system would you recommend, and why?
b) The business owner also has a server in the office, and they require an OS that can handle multiple
user connections, provide file sharing, and ensure data security. What classification of operating
system would you recommend for the server, and why?
c) The business owner plans to integrate a real-time system for monitoring and controlling
manufacturing equipment. What classification of operating system would you recommend for this
specialized task, and why?
6. Find the average waiting time (A.W.T) and (A.T.A.T) for executing the following process using
Preemptive short-job first
Process P1 P2 P3 P4 P5
Burst time 5 13 8 4 10
Arrival time 2 3 0 5 1
7. Three processes A, B and C each execute a loop of 100 iterations. In each iteration of the loop, a
process performs a single computation that requires tc CPU milliseconds and then initiates a single
I/O operation that lasts for tio milliseconds. It is assumed that the computer where the processes
execute has sufficient number of I/O devices and the OS of the computer assigns different I/O devices
to each process. Also, the scheduling overhead of the OS is negligible. The processes have the
following characteristics:
Process id tc tio
A 100 ms 500 ms
B 350 ms 500 ms
C 200 ms 500 ms
The processes A, B, and C are started at times 0, 5 and 10 milliseconds respectively, in a pure time
sharing system (round robin scheduling) that uses a time slice of 50 milliseconds. Calculate the time
in milliseconds at which process C would complete its first I/O operation is
8. You are the administrator of a multi-user server. One of the users complains that their commands are
not executing as expected. Upon investigation, you find that their processes are stuck in the "Blocked"
state due to waiting for a network resource. Explain how processes transition between states and how
you would address this issue.
9. Imagine a simple round-robin scheduling algorithm with a time quantum of 10 milliseconds. Two
processes, X and Y, are competing for CPU time. Process X consistently uses less than 10 milliseconds
per quantum, while process Y requires more than 10 milliseconds to complete. How would the CPU
scheduler handle this situation, and what might be the user's experience with these processes?
10. Imagine you're working with a group of non-technical colleagues who are curious about computers.
While discussing operating systems, they ask, "Why do we even need an operating system in our
computers?" How would you explain the main purpose and significance of an operating system in a
relatable scenario or example?
11. If Mr. Abhishek aims to run his five programs, each of which typically takes 15 minutes to complete,
but he's constrained to a time window of only 15-16 minutes, which operating system would you
recommend for optimizing his task? Please explain your choice.
12. Under what circumstances, it is suitable to use time-sharing system rather than a PC or a single user
workstation? Explain.
13. Examine the given lines of code. How many numbers of Processes created?
#include <stdio.h>
#include <unistd.h>
int main()
{
int i;
for (i = 0; i < 5; i++)
fork();
return 0;
}
14. Consider a set of 5 processes whose arrival time, CPU time needed and the priority are given below:
Process number Arrival time(ms) CPU time Priority
p1 0 10 5
p2 0 5 2
p3 2 3 1
p4 5 20 4
p5 10 2 3
If the CPU scheduling policy is SJF, the average waiting time (without preemption) will be?
15. Consider the 3 processes, P1, P2 and P3 shown in the table.
Process Arrival time Time Units Required
P1 0 5
P2 1 7
P3 3 4
The completion order of the 3 processes under the policy round robin scheduling with CPU quantum
of 2 time units is
16. Consider the following set of processes, with length of CPU bursts given in Millisecond as follows:
Process Burst Time Arrival Time Priority
P1 8 0 3
P2 1 1 1
P3 3 2 2
P4 2 3 3
P5 6 4 4
a. Draw the Gantt Charts for FCFS, SJF, Preemptive priority and RR(Quantum=2)
b. What is the turnaround time of each process for above algorithm?
c. What is the waiting time of each process for each of the above algorithm?
d. Which algorithm results in minimum average waiting time?
17. You are part of a team working on a robotics project for an industrial automation task. Your team
needs to choose an appropriate operating system for the robot's control unit. The choice of operating
system will impact the robot's performance and reliability.
a) Explain the key characteristics and requirements of the robotics project that should influence your
choice of operating system classification.
b) Considering the project's requirements, justify whether a real-time operating system, a general-
purpose operating system, or a specialized embedded operating system would be most suitable for the
robot's control unit. Provide reasons for your choice.
c) Outline the potential advantages and drawbacks of your selected operating system classification in
the context of the robotics project.
18. A software development team is working on a complex project with multiple c omponents. Describe
how you would use process states like "New," "Ready," "Running," and "Terminated" to manage the
software development lifecycle, from project initiation to final delivery.
19. You are managing a real-time operating system for an autonomous drone. The drone has to perform
various tasks with different deadlines, such as navigation and obstacle avoidance. How would you
choose a scheduling algorithm to ensure that critical tasks meet their deadlines while maximizing CPU
utilization?
20. In a computer lab at a university, students are using shared workstations for various tasks, including
coding, word processing, and browsing. Describe how a fair-share scheduling algorithm could be
employed to ensure that all students have a fair opportunity to use the CPU resources, regardless of
their specific tasks.
21. Consider a GLA university computer lab 330 where various students and researchers have access to
a shared computing environment. Some students want to use this lab for doing programming
assignments and data analysis while Professors want to utilize this lab to train their deep learning
models. Describe which type of operating system in this lab can be utilized that effectively allocates
resources, such as CPU time, memory, and peripheral devices, to ensure fairness and optimize
productivity among multiple users.
22. Predict the output?
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
void forkexample()
{
int x = 1;
if (fork() == 0)
printf("Child has x = %d\n", ++x);
else
printf("Parent has x = %d\n", --x);
}
int main()
{
forkexample();
return 0;
}
23. Consider the following set of processes that need to be scheduled on a single CPU. All the times are
given in milliseconds.
Using the shortest remaining time first scheduling algorithm, the average process turnaround time (in
msec) is?
24. For the processes listed in the following table, which of the following scheduling schemes will give
the lowest average turnaround time?
a) First Come First Serve
b) Non – preemptive Shortest Job First
c) Shortest Remaining Time
25. Suppose that the following processes arrive for execution at the times indicated. Each process willrun
for the amount of time listed. In answering the questions, use nonpreemptive scheduling, and base all
decisions on the information you have at the time the decision must be made.
a. What is the average turnaround time for these processes with the FCFS scheduling algorithm?
b. What is the average turnaround time for these processes with the SJF scheduling algorithm?
c. The SJF algorithm is supposed to improve performance, but notice that we chose to run process P1
at time 0 because we did not know that two shorter processes would arrive soon. Compute what the
average turnaround time will be if the CPU is left idle for the first 1 unit and then SJF scheduling is
used. Remember that processes P1 and P2 are waiting during this idle time, so their waiting time may
increase. This algorithm could be known as future-knowledge scheduling.
26. Consider the following set of processes, with the length of the CPU-burst time given in milliseconds:
Burst
Process Time Priority
P1 10 3
P2 1 1
P3 2 3
P4 1 4
P5 5 2
The processes are assumed to have arrived in the order P 1, P 2, P 3, P 4, P 5, all at time 0.
a. Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF, a non
preemptive priority (a smaller priority number implies a higher priority), and RR scheduling.
b. What is the turnaround time of each process for each of the scheduling algorithms in part a?
c. What is the waiting time of each process for each of the scheduling algorithms in part a?
Assume an operating system maps user-level threads to the kernel using the many-to- many model
where the mapping is done through LWPs. Furthermore, the system allows the developers to create
real-time threads. Is it necessary to bound a real-time thread to an LWP? Explain.
27. You are developing an operating system for a personal computer. A user opens a word processing
application and starts typing a document. Describe the process creation steps that occur from the user's
action to the actual execution of the word processing program.
28. In a real-time control system for an autonomous robot, there are multiple processes responsible for
sensor data processing, decision-making, and motor control. Describe how you would manage and
prioritize processes in different states to ensure the robot's responsiveness to changing environmental
conditions.
29. A user on a personal computer has opened multiple applications, including a text editor, a web
browser, and a media player. Describe how the operating system handles process states such as
"Running," "Ready," and "Blocked" to provide a smooth user experience, especially when switching
between applications.
30. Assume that, you work for a space exploration company, and your team is responsible for
programming the software that controls a rover on a distant planet. Your colleague, who is new to this
project, asks, "What exactly is a real-time operating system, and why are we using it for the rover's
software?" How would you explain the concept of a real-time operating system and its importance in
the context of controlling the rover's actions and data processing on a distant planet?
The total number of child processes created is _____ and Justify your output.
32. In a multiprogramming and time-sharing environment, several users share the system simultaneously.
This situation can result in various security problems. What are two such problems?
33. Assume arrival order is: P1, P2, P3, P4, P5 at time 0, 1, 2, 3, 4 respectively and a smaller priority
number implies a higher priority. Draw the Gantt charts for pre-emptive and non-pre-emptive priority
scheduling. Calculate Average Turnaround Time and Average Waiting Time.
34. Consider a set of 5 processes whose arrival time, CPU time needed and the priority are given below:
Process number Arrival time(ms) CPU time Priority
p1 0 10 5
p2 0 5 2
p3 2 3 1
p4 5 20 4
p5 10 2 3
If the CPU scheduling policy is SJF, the average waiting time (with preemption) will be?
35. Find the waiting time of P4 process using priority scheduling algorithm (Assume lowest number has
highest priority).
Process P1 P2 P3 P4 P5
Burst time 5 13 8 6 12
Priority 1 3 0 4 2
36. The traditional UNIX scheduler enforces an inverse relationship between priority numbers and
priorities: the higher the number, the lower the priority. The scheduler recalculates process priorities
once per second using the following function: Priority = (recent CPU usage / 2) + base where base =
60 and recent CPU usage refers to a value indicating how often a process has used the CPU since
priorities were last recalculated. Assume that recent CPU usage for process P1 is 40, for process P2 is
18, and for process P3 is 10. What will be the new priorities for these three processes when priorities
are recalculated? Based on this information, does the traditional UNIX scheduler raise or lower the
relative priority of a CPU-bound process?
37. You are designing a task scheduler for an operating system that supports both foreground and
background tasks. Explain how the "Ready" and "Running" states are managed in the context of a
multi-core CPU, and how the scheduler decides which process to move from "Ready" to "Running."
38. In a multi-user operating system, several users are running CPU-bound tasks. One user has a high-
priority task, while the others have lower-priority tasks. Explain how a priority-based scheduling
algorithm would handle this situation and its potential advantages and drawbacks
39. In a computer lab, there are multiple student workstations running various applications. A student is
complaining that their computer is running slowly because of a CPU-intensive application running on
another workstation. How could a CPU scheduler address this issue and ensure fair CPU allocation
among all users?
40. Consider you're in a tech support role, and a colleague from another department asks you to clarify
what the term "kernel" means in the context of an operating system. They also want to know about
the different types of kernels that exist. How would you explain the concept of a kernel, and what
examples?
41. There are two different ways that commands can be processed by a command interpreter. One way is
to allow the command interpreter to contain the code needed to execute the command. The other way
is to implement the commands through system programs. Compare and contrast the two approaches.
42. The issue of resource utilization shows up in different forms in different types of operating systems.
List what resources must be managed carefully in the following settings:
a. Mainframe or minicomputer systems
b. Workstations connected to servers
printf("forked\n");
return 0;
}
44. Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units
respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time
doing computation, and the last 10% of time doing I/O again. The operating system uses a shortest
remaining compute time first scheduling algorithm and schedules a new process either when the
running process gets blocked on I/O or when the running process finishes its compute burst. Assume
that all I/O operations can be overlapped as much as possible. For what percentage of does the CPU
remain idle?
45. Consider the following processes, with the arrival time and the length of the CPU burst given in
milliseconds. The scheduling algorithm used is preemptive shortest remaining-time first.
The average turnaround time of these processes is milliseconds ________
46. Consider the following table of arrival time and burst time for three processes P0, P1 and P2.
The pre-emptive shortest job first scheduling algorithm is used. Scheduling is carried out only at
arrival or completion of processes. What is the average waiting time for the three processes?
47. Consider the set of 4 processes whose arrival time and burst time are given below -
If the CPU scheduling policy is Shortest Remaining Time First, calculate the average waiting time
and average turnaround time.
48. While using your computer, you notice that one application has become unresponsive. Describe how
you would use the operating system's task manager or equivalent feature to identify and terminate the
unresponsive process.
49. How does the FCFS scheduling algorithm work in the context of allocating computers to students in
the lab? What are the potential advantages and drawbacks of using FCFS for this purpose?
50. Imagine you're leading a team meeting at a software development company. You want to discuss the
various types of operating systems and their pros and cons to help your team make informed decisions
about which OS to use for their upcoming project. How would you guide the discussion, explaining
the different types of operating systems while highlighting their advantages and disadvantages?