0% found this document useful (0 votes)
6 views11 pages

OS Assignment

There are three levels of schedulers in an operating system: 1. The high-level scheduler manages long-term planning and balances system load. 2. The intermediate-level scheduler handles memory swapping and optimization. 3. The dispatcher makes short-term decisions by selecting the next process for the CPU. The document then discusses the responsibilities of each scheduler level and distinguishes between scheduling policies and mechanisms. It also matches common scheduling objectives like fairness, throughput and response time to examples. Finally, it lists scheduling criteria like I/O boundedness, priority and waiting time that are used to determine which processes are scheduled.

Uploaded by

akramullah khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views11 pages

OS Assignment

There are three levels of schedulers in an operating system: 1. The high-level scheduler manages long-term planning and balances system load. 2. The intermediate-level scheduler handles memory swapping and optimization. 3. The dispatcher makes short-term decisions by selecting the next process for the CPU. The document then discusses the responsibilities of each scheduler level and distinguishes between scheduling policies and mechanisms. It also matches common scheduling objectives like fairness, throughput and response time to examples. Finally, it lists scheduling criteria like I/O boundedness, priority and waiting time that are used to determine which processes are scheduled.

Uploaded by

akramullah khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Assignment No: 1

Summer Semester 2023

Name: Muhammad Afaq


Registration No: 20pwbcs0763
Subject: Operating System
Submitted To: Mam Wajeeha Khalil
8.1.Distinguish among the following three levels of schedulers. a. high
level scheduler b. intermediate-level scheduler c. dispatcher
Answer:
There are three levels of schedulers:
a. High-Level Scheduler:
Selects which processes enter the system.
Balances system load and resource usage.
Long-term planning.

b. Intermediate-Level Scheduler:
Manages process' memory swapping.
Optimizes memory utilization.
Medium-term management.

c. Dispatcher:
Selects next process for CPU.
Performs context switching.
Short-term decision-making.
8.2 Which level of scheduler should make a decision on each of the
following questions? a. Which ready process should be assigned a
processor when one becomes available? b. Which of a series of waiting
batch processes that have been spooled to disk should next be initiated?
c. Which processes should be temporarily suspended to relieve a short-
term burden on the processor? d. Which temporarily suspended process
that is known to be I/O bound should be activated to balance the
multiprogramming mix?

Answer:
There are responsibilities of the three levels of schedulers:
 Long-term scheduler decides which processes to bring into the
memory from the disk.
 Medium-term scheduler temporarily suspends processes, moves
processes between the ready queue and the wait queue, and decides
which processes to swap out of memory.
 Short-term scheduler selects a process from the ready queue and
allocates the CPU to it.
Here is a table summarizing the responsibilities of the three levels of
schedulers in a shorter form:
Scheduler Responsibility
Long-term Brings processes into memory
Medium-term Suspends, moves, swaps processes
Short-term Selects, allocates CPU

8.3 Distinguish between a scheduling policy and a scheduling mechanism .


Answer:
A scheduling policy is a set of rules that determines how the operating
system will choose which process to run next. Some common scheduling
policies include first-come, first-served (FCFS), shortest job first (SJF), and
priority scheduling.

A scheduling mechanism is the method by which the operating system


implements the scheduling policy. Some common scheduling mechanisms
include round robin, priority queue, and multilevel feedback queue.

The main difference between a scheduling policy and a scheduling


mechanism is that the policy defines the criteria for choosing the next
process to run, while the mechanism defines the procedure for
implementing the policy.

For example, the FCFS policy states that the next process to run should be
the one that has been waiting in the queue the longest. The round robin
mechanism implements the FCFS policy by giving each process a time slice,
and then rotating the CPU to the next process when the time slice expires.

Here is a table summarizing the differences between scheduling policies


and scheduling mechanisms:
Scheduling policy Scheduling mechanism

Defines the criteria for choosing the Defines the procedure for
next process to run implementing the policy
Examples: FCFS, SJF, priority Examples: round robin, priority
scheduling queue, multilevel feedback queue

8.4 The following are common scheduling objectives. a. to be fair b. to


maximize throughput c. to maximize the number of interactive users
receiving acceptable response times d. to be predictable e. to minimize
overhead f. to balance resource utilization g. to achieve a balance
between response and utilization h. to avoid indefinite postponement i.
to obey priorities j. to give preference to processes that hold key
resources k. to give a lower grade of service to high overhead processes l.
to degrade gracefully under heavy loads Which of the preceding
objectives most directly applies to each of the following? i. If a user has
been waiting for an excessive amount of time, favor that user. ii. The user
who runs a payroll job for a 1000- employee company expects the job to
take about the same amount of time each week. iii. The system should
admit processes to create a mix that will keep most devices busy. iv. The
system should favor important processes. v. An important process arrives
but cannot proceed because an unimportant process is holding the
resources the important process needs. vi. During peak periods, the
system should not collapse from the overhead it takes to manage a large
number of processes. vii. The system should favor I/O-bound processes.
viii. Context switches should execute as quickly as possible.

Answer:
The following are the scheduling objectives and their corresponding
descriptions:
 Fairness : All processes should be given an equal chance to run,
regardless of their priority or other factors.
 Throughput : The number of processes that can be completed per
unit time.
 Interactive response time : The amount of time it takes for a process
to receive a response from the system.
 Predictability : The ability to predict how long a process will take to
run.
 Overhead : The amount of time and resources that are used by the
scheduling algorithm.
 Resource utilization : The extent to which the system's resources are
being used.
 Response and utilization balance : The trade-off between giving
processes a good response time and ensuring that the system's
resources are being used efficiently.
 Indefinite postponement : The situation where a process is never
given a chance to run.
 Obeying priorities : The scheduling algorithm should give higher
priority processes a better chance to run.
 Giving preference to processes that hold key resources : The
scheduling algorithm should give higher priority to processes that are
holding key resources that are needed by other processes.
 Giving a lower grade of service to high overhead processes : The
scheduling algorithm should give lower priority to processes that
have a high overhead.
 Degrading gracefully under heavy loads : The system should continue
to function even when it is under heavy load.
Now, let's look at the specific scheduling objectives that are most directly
applicable to each of the given cases:
 Case i : This case is about fairness, so the most directly applicable
objective is fairness.
 Case ii : This case is about predictability, so the most directly
applicable objective is predictability.
 Case iii : This case is about resource utilization, so the most directly
applicable objective is resource utilization.
 Case iv : This case is about favoring important processes, so the most
directly applicable objective is obeying priorities.
 Case v : This case is about avoiding indefinite postponement, so the
most directly applicable objective is avoiding indefinite
postponement.
 Case vi : This case is about minimizing overhead, so the most directly
applicable objective is minimizing overhead.
 Case vii : This case is about favoring I/O-bound processes, so the most
directly applicable objective is favoring I/O-bound processes.
 Case viii : This case is about context switches, so the most directly
applicable objective is degrading gracefully under heavy loads.

8.5 The following are common scheduling criteria. a. I/O boundedness of a


process b. processor boundedness of a process c. whether the process is
batch or interactive d. urgency of a fast response e. process priority f.
frequency of a process is being preempted by higherpriority processes g.
priorities of processes waiting for resources held by other processes h.
accumulated waiting time i. accumulated execution time j. estimated run-
time-to-completion. For each of the following, indicate which of the
preceding scheduling criteria is most appropriate. i. In a real-time
spacecraft monitoring system, the computer must respond immediately to
signals received from the spacecraft. ii. Although a process has been
receiving occasional service, it is making only nominal progress. iii. How
often does the process voluntarily give up the processor for I/O before its
quantum expires? iv. Is the user present and expecting fast interactive
response times, or is the user absent? v. One goal of processor scheduling
is to minimize average waiting times. vi. Processes holding resources in
demand by other processes should have higher priorities. vii. Nearly
complete processes should have higher priorities.
Answer:
The following are the scheduling criteria and their corresponding
descriptions:

I/O boundedness of a process : A process is I/O bounded if it spends most of


its time waiting for I/O operations to complete.
Processor boundedness of a process : A process is processor bounded if it
spends most of its time executing instructions.
Whether the process is batch or interactive : A batch process is a process
that does not require any user interaction. An interactive process is a
process that does require user interaction.
Urgency of a fast response : The urgency of a fast response is the degree to
which a process needs to be able to respond to events quickly.
Process priority : The priority of a process is a measure of its importance.
Frequency of a process is being preempted by higher-priority processes :
The frequency of a process being preempted by higher-priority processes is
a measure of how often the process is interrupted.
Priorities of processes waiting for resources held by other processes : The
priorities of processes waiting for resources held by other processes is a
measure of how important the processes are that are waiting for resources.
Accumulated waiting time : The accumulated waiting time of a process is
the amount of time the process has spent waiting for the CPU.
Accumulated execution time : The accumulated execution time of a process
is the amount of time the process has spent executing instructions.
Estimated run-time-to-completion : The estimated run-time-to-completion
of a process is the amount of time the process is expected to take to
complete.
Now, let's look at the specific scheduling criteria that are most appropriate
to each of the given cases:

Case i : This case is about a real-time system, so the most appropriate


scheduling criterion is urgency of a fast response.
Case ii : This case is about a process that is making slow progress, so the
most appropriate scheduling criterion is accumulated waiting time.
Case iii : This case is about a process that is voluntarily giving up the CPU for
I/O, so the most appropriate scheduling criterion is frequency of a process
is being preempted by higher-priority processes.
Case iv : This case is about an interactive process, so the most appropriate
scheduling criterion is urgency of a fast response.
Case v : This case is about minimizing average waiting times, so the most
appropriate scheduling criterion is accumulated waiting time.
Case vi : This case is about processes holding resources in demand by other
processes, so the most appropriate scheduling criterion is priorities of
processes waiting for resources held by other processes.
Case vii : This case is about nearly complete processes, so the most
appropriate scheduling criterion is estimated run-time-to-completion.

8.6 State which of the following are true and which false. Justify your
answers. a. A process scheduling discipline is preemptive if the processor
cannot be forcibly removed from a process. b. Real-time systems generally
use preemptive processor scheduling. c. Timesharing systems generally
use nonpreemptive processor scheduling. d. Turnaround times are more
predictable in preemptive than in nonpreemptive systems. e. One
weakness of priority schemes is that the system will faithfully honor the
priorities, but the priorities themselves may not be meaningful.
Answer:
Here are the statements about scheduling disciplines
a. False. A preemptive scheduling discipline is where the processor can be
forcibly removed from a running process.
b. True. Real-time systems need to meet deadlines, so preempting a
running process is important if a higher priority process arrives.
c. False. Timesharing systems use preemptive scheduling to ensure that all
users get a fair share of the CPU.
d. False. Turnaround time is unpredictable in preemptive scheduling
because the process can be preempted and put back in the queue multiple
times.
e. True. Priority schemes are based on the assumption that the priorities
assigned to processes are meaningful. However, this is not always the case.

8.7 Why should processes be prohibited from setting the


interrupting clock?
Answer:
Here is a explanation of why processes should not be allowed to set the
interrupting clock:

 It can lead to race conditions and deadlocks.


 It can lead to security vulnerabilities.
 It can make it difficult to debug the system.
 It can make it difficult to predict the behavior of the system.
In short, allowing processes to set the interrupting clock can lead to many
problems, so it is best to let the operating system handle this task.

8.8 State which of the following refer to "static priorities"


and which to "dynamic priorities."
a. are easier to implement
b. require less runtime overhead
c. are more responsive to changes in a process's environment
d. requires more careful deliberation over the initial priority value chosen.

Answer:
Here is a brief explanation of each of the statements:
 Static priorities are priorities that are assigned to processes when
they are created. They do not change over time, regardless of the
process's behavior.
 Dynamic priorities are priorities that can change over time, based on
the process's behavior. For example, a process's priority might be
increased if it is waiting for a long time for a resource.
Based on these definitions, the following statements are true:
 Static priorities are easier to implement because the operating
system does not need to track the process's behavior over time.
 Static priorities require less runtime overhead because the operating
system does not need to update the process's priority as often.
 Dynamic priorities are more responsive to changes in a process's
environment because the operating system can adjust the process's
priority as needed.
 Static priorities require more careful deliberation over the initial
priority value chosen because the priority cannot be changed later.

8.9 Give several reasons why deadline scheduling is complex.

Answer:
 Accurately predicting task execution time: It is difficult to predict the
execution time of tasks, especially for tasks that are I/O-bound or that
have unpredictable behavior.
 Minimizing average waiting time: It is difficult to minimize the average
waiting time of all tasks, especially if there are many tasks with different
deadlines.
 Avoiding starvation: It is difficult to avoid starvation, which is the situation
where a task is never given a chance to run because it is always
preempted by higher priority tasks.
 Handling preemptions: It is difficult to handle preemptions gracefully, which
means that the algorithm must be able to quickly re-schedule tasks that
have been preempted, and it must also ensure that the tasks still meet
their deadlines.
 Dealing with uncertainty: It is difficult to deal with uncertainty in the system,
such as uncertainty about the arrival time of tasks, the execution time of
tasks, and the availability of resources.

Overall, deadline scheduling is a complex problem because it involves many


factors that are difficult to predict and control.

8.10 Give an example showing why FIFO is not an appropriate processor


scheduling scheme for interactive users.

Answer:
Here is an example showing why FIFO is not an appropriate processor
scheduling scheme for interactive users:
Suppose there are two processes, P1 and P2, running on a single processor
system. P1 is a long-running batch process, while P2 is an interactive process
that is waiting for user input.

Under FIFO scheduling, P1 will be given the CPU first, even though P2 is waiting
for user input. This means that P2 will have to wait until P1 finishes running
before it can get a chance to run. This can lead to a poor user experience, as the
user will have to wait a long time for their process to start running.

In contrast, a scheduling scheme that prioritizes interactive processes, such as


round-robin scheduling, would give P2 a chance to run sooner. This would
improve the user experience, as the user would not have to wait as long for their
process to start running.

Here are some other reasons why FIFO is not an appropriate processor
scheduling scheme for interactive users:

 It can lead to starvation, where interactive processes are never given a


chance to run because they are always preempted by long-running batch
processes.
 It can lead to unpredictable response times, as the time it takes for an
interactive process to run can vary depending on the arrival time of other
processes.
 It can lead to poor system utilization, as the CPU may be idle while
interactive processes are waiting to run.

Overall, FIFO is not an appropriate processor scheduling scheme for interactive


users because it can lead to poor user experience, starvation, unpredictable
response times, and poor system utilization.

8.11 Using the example from the previous problem, show why round-robin
is a better scheme for interactive users.

Answer:

 Round-robin scheduling gives each process a fair chance to run,


regardless of its priority.
 This prevents interactive processes from being starved by long-running
batch processes.
 Round-robin scheduling is simple to implement and understand.
 It can be used to improve the performance of interactive systems.

Overall, round-robin scheduling is a good choice for scheduling interactive


processes because it is fair, simple, and can improve performance.
8.12 Determining the quantum is a complex and critical task.
Assume that the average context-switching time between processes is s,
and the average amount of time an I/O-bound process uses before
generating an I/O request is t (t >> s). Discuss
the effect of each of the following quantum settings, q.
a. q is slightly greater than zero
b. q = s
c. s <q <t
d. q-t
e. q>t
f. q is an extremely large number.

Answer:
A small quantum size will lead to frequent preemptions, which can reduce
performance.
A large quantum size will reduce preemptions, but it can lead to starvation
for I/O-bound processes.
The ideal quantum size is slightly greater than the time it takes for an I/O-
bound process to generate an I/O request.
Here are some additional considerations when choosing a quantum size:

The number of processes in the system.


The type of processes in the system.
The desired trade-off between performance and overhead.
The best way to choose a quantum size is to experiment with different
values and see what works best for the specific system.

In your specific example, where the average context-switching time is s and


the average amount of time an I/O-bound process uses before generating
an I/O request is t (t >> s), the ideal quantum size would be slightly greater
than t. This would allow I/O-bound processes to run for a while without
being preempted, but it would also prevent them from monopolizing the
CPU.

However, it is important to note that the ideal quantum size can vary
depending on the specific system. The best way to choose a quantum size is
to experiment with different values and see what works best for the specific
system.

8.14 State why each of the following is incorrect. a. SPF never has a higher
throughput than SRT. b. SPF is fair. c. The shorter the process, the better
the service it should receive. d. Because SPF gives preference to short
processes, it is useful in timesharing.

Answer:
 a. SPF never has a higher throughput than SRT.

This statement is incorrect because SPF can have a higher throughput than
SRT in some cases. For example, if there are a lot of short processes in the
system, then SPF can give them all a chance to run before a long process
gets a chance to run. This can lead to higher throughput than SRT, which
would only give the long process a chance to run.

 b. SPF is fair.

This statement is incorrect because SPF is not fair to all processes. It gives
preference to short processes, which means that long processes may have
to wait a long time to run. This can be unfair to processes that have
important deadlines.

 c. The shorter the process, the better the service it should receive.

This statement is incorrect because it is not always true. For example, a long
process that is close to finishing may be more important than a short
process that is just starting. In this case, it would be better to give the long
process the CPU, even though it is longer.

 d. Because SPF gives preference to short processes, it is useful in


timesharing.

This statement is incorrect because SPF is not always useful in timesharing.


Timesharing systems are designed to give all users a fair share of the CPU,
regardless of the length of their processes. SPF can give preference to short
processes, which can lead to starvation for long processes.

8.15 State some weaknesses in SRT. How would you modify


the scheme to get better performance?

You might also like