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

OS(4)

The document outlines a series of programming tasks focused on simulating various algorithms related to operating systems, including CPU scheduling, disk scheduling, page replacement, frame allocation, and load balancing. Each program requires the formulation of simulation assumptions and aims to demonstrate the performance of different algorithms using the same input data. The document also provides links to additional resources for further learning and understanding of the algorithms discussed.

Uploaded by

Moji Bake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

OS(4)

The document outlines a series of programming tasks focused on simulating various algorithms related to operating systems, including CPU scheduling, disk scheduling, page replacement, frame allocation, and load balancing. Each program requires the formulation of simulation assumptions and aims to demonstrate the performance of different algorithms using the same input data. The document also provides links to additional resources for further learning and understanding of the algorithms discussed.

Uploaded by

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

Page in Polish about Operation Systems

https://www.ii.pwr.edu.pl/~juszczyszyn/so.htm

Each program should present the results obtained using


different algorithms for the same input data.

Description of algorithms for 1. program (cpu


scheduling algorithms)
Task:
A program should simulate the operation of algorithms for
scheduling access to the processor for requesting processes.
The program should show the average waiting time of
processes for various scheduling algorithms:
- First Come First Serve (FCFS) CPU Scheduling (Processes
with different arrival times)/FIFO (First-In-First-Out),
- Shortest Job First (or SJF) CPU Scheduling (Non-Preemptive
Scheduling),
- Shortest Job First (or SJF) CPU Scheduling (Preemptive
Scheduling),
- Round Robin (RR) (you can change a fixed time slice or
"quantum") - if the quantum is very large, the algorithm
works like FCFS – it presents the same results.

You should formulate the simulation assumptions yourself.


Tips:
- algorithms should be checked for the same test data (i.e.,
the same test sequences of reporting processes),
- there should be more test sequences (20? 50?); the result
will be average values,
- each sequence will contain N processes with random
processor phase lengths (the distribution of phase lengths
should be selected to correspond to the situation in the
real system, where it is not uniform), reporting at random
moments (select parameters so that a queue of processes
waiting for processor allocation can be created).
- possible process representation: record (number, burst
time –processor phase length, arrival time, waiting time
/initially equal to 0/...)
The obtained results should be explained, and you should be
ready to draw conclusions from them... :)
The ability to control simulation parameters is welcome.
When passing, be prepared for any questions regarding the
material discussed during the lecture and related to the task
topic...

More information:
GeeksforGeeks | A computer science portal for
geeks
 https://www.geeksforgeeks.org/comparison-of-different-
cpu-scheduling-algorithms-in-os/
 https://www.geeksforgeeks.org/first-come-first-serve-
cpu-scheduling-non-preemptive/
 https://www.geeksforgeeks.org/program-for-shortest-job-
first-or-sjf-cpu-scheduling-set-1-non-preemptive/
 https://www.geeksforgeeks.org/preemptive-and-non-
preemptive-scheduling/
 https://www.geeksforgeeks.org/round-robin-scheduling-
in-operating-system/
NESO ACADEMY on YouTube
 https://www.youtube.com/watch?v=EWkQl0n0w5M
 https://www.youtube.com/watch?v=pVzb3TUcDLo
 https://www.youtube.com/watch?v=4DhFmL-6SDA
 https://www.youtube.com/watch?v=bWHFY8-rL5I
 https://www.youtube.com/watch?v=7DoP1L9nAAs
 https://www.youtube.com/watch?v=VSMAjMfJ6KQ
 https://www.youtube.com/watch?v=8-BUGte27sk
 https://www.youtube.com/watch?v=t0g9b3SJECg
 https://www.youtube.com/watch?v=lpM14aWgl3Q
 https://www.youtube.com/watch?v=ypOnf9mnFYg
 https://www.youtube.com/watch?v=YzBBJYfwdi8
 https://www.youtube.com/watch?v=7TpxxTNrcTg
 https://www.youtube.com/watch?v=QlCmgBOMjlI
 https://www.youtube.com/watch?v=wioTortHb_g
Description of algorithms for 2. program (disk
scheduling algorithms)
The program should simulate the operation of disk access
planning algorithms.
- In our case, 'disk' is a linearly ordered sequence of blocks
with numbers from 1 to MAX.
- The criterion for evaluating the algorithms will be the
total seek time/head movements, which, as is known,
is proportional to the time of order execution.
The program should simulate the operation of the following
algorithms:
- FCFS (First Come First Serve),
- SSTF (Shortest Seek Time First),
- SCAN (Elevator Algorithm),
- C-SCAN (Circular Elevator Algorithm).
The program should also predict the situations of real-time
applications (this can be for any algorithm, e.g. for only one,
SSTF or FCFS), which must be handled using EDF and/or FD-
SCAN. Should the results be provided?
Short explanation of real-time algorithms
 EDF – Earliest Deadline First – is an "equivalent of SJF",
handles requests in order from the shortest to the
longest deadline (priority: deadline – time to completion)
 FD-SCAN – Feasible-Deadline Scan – a head moves
towards the nearest (on the disk – priority:
proximity/distance on the disk) POSSIBLE DEADLINE but
executes all requests that were in the space between the
current position and the position of the request it is heading
to.
 However, if it is calculated that moving the head to the
desired location will take longer than the deadline indicates,
then such action will not be taken. Abandoned requests
should also be counted.
Difference between algorithms: EDF vs. SSTF  execution
deadlines are considered instead of distances. For each
algorithm, including real-time (EDF, FD-SCAN) the program
should return a total seek time/head movements.
After executing real-time requests, the remaining requests are
executed according to the previous algorithm, e.g. SSTF, FIFO,
etc.
Only one real-time algorithm can be present in the program:
EDF or FD-SCAN.
The program should show the total seek time/head
movements. We are looking for an algorithm where this sum of
distances will be as small as possible.
NOTE!
The formulation of simulation conditions not mentioned above is
your responsibility. I mean:
- size of the 'disk' (number of blocks),
- number and method of generating requests (full queue from
the beginning? requests in progress? distribution of requests –
even, other?),
- method of considering real-time handling of requests
- other... >>> the ability to justify the adopted solution is
welcome.

More information:
GeeksforGeeks | A computer science portal for
geeks
 https://www.geeksforgeeks.org/disk-scheduling-algorithms/
 https://www.geeksforgeeks.org/fcfs-disk-scheduling-
algorithms/
 https://www.geeksforgeeks.org/sstf-full-form/
 https://www.geeksforgeeks.org/program-for-sstf-disk-
scheduling-algorithm/
 https://www.geeksforgeeks.org/scan-elevator-disk-
scheduling-algorithms/
 https://www.geeksforgeeks.org/c-scan-disk-scheduling-
algorithm/
 https://www.geeksforgeeks.org/earliest-deadline-first-
edf-cpu-scheduling-algorithm/
 https://www.geeksforgeeks.org/look-disk-scheduling-
algorithm/
NESO ACADEMY on YouTube
 https://www.youtube.com/watch?v=MSB2GZ0xydc
 https://www.youtube.com/watch?v=MiDFgPYrjBk
Description of algorithms for 3. program (page
replacement algorithms)
In most systems, the size of a process's virtual address space is
much larger than the available main memory (RAM).
You should write a program that will contain simulations of 5
page replacement algorithms.
You should formulate your own simulation assumptions:
- size of virtual memory (number of pages),
- size of physical memory (number of frames),
- length (should be significant – min. 1000) and method of
generating a sequence of page references (it is
necessary to consider the principle of locality of
references).
Program operation:
- generate a random sequence of n page references,
- for the generated sequence, show the number of page
faults for various page replacement algorithms:
1) FCFS (FIFO),
2) FCFS (FIFO) with second chance (ALRU),
3) LRU,
4) OPT,
5) RAND.
Simulations should be performed (on the same test string) for a
different number of frames (e.g., several (5, 10, 20?) values
provided by the user).

More information:
GeeksforGeeks | A computer science portal for
geeks
 https://www.geeksforgeeks.org/virtual-memory-in-
operating-system/
 https://www.geeksforgeeks.org/page-fault-handling-in-
operating-system/
 https://www.geeksforgeeks.org/page-replacement-
algorithms-in-operating-systems/
 https://www.geeksforgeeks.org/program-page-
replacement-algorithms-set-2-fifo/
 https://www.geeksforgeeks.org/page-faults-in-lru-
implementation/
 https://www.geeksforgeeks.org/program-for-least-
recently-used-lru-page-replacement-algorithm/
 https://www.geeksforgeeks.org/videos/random-page-
replacement-algorithm-in-os/
Wikipedia.com
 https://en.wikipedia.org/wiki/Page_replacement_algorithm
YouTube
 https://www.youtube.com/watch?v=puobwv1xjqc
 https://www.youtube.com/watch?v=A9WLYbE0p-I&t=450s
 https://www.youtube.com/watch?v=fGP6VHxqkIM
 https://www.youtube.com/watch?v=p9yZNLeOj4s
 https://www.youtube.com/watch?v=qlH4-oHnBb8
 https://www.youtube.com/watch?v=59rEMnKWoS4
Description of algorithms for 4. program (frame
allocation algorithms)
This is an extension of program no. 4. You should assume that:
- a certain number of processes (~10) are running in the
system,
- each process uses its own set of pages (the locality
principle still applies),
- the global reference sequence is the result of combining
the reference sequences generated by individual
processes (each generates many, not just one),
- the system allocates a certain number of frames to each
based on the following methods:
1. Equal allocation,
2. Proportional allocation (frames are allocated based on
the size of the processes and not on the number of
references!!!!),
3. Page fault frequency (Page fault rate control),
4. Zone model (working set).
- pages are replaced according to LRU.
How do frame allocation strategies affect the results (number of
page faults – globally, for each process)?
The program should print the adopted simulation assumptions
on the screen. The ability to change them by the user is
welcome.
Conclusions?

More information:
1. https://www.geeksforgeeks.org/operating-system-
allocation-frames/
2. https://www.geeksforgeeks.org/difference-between-
multitasking-multithreading-and-multiprocessing/
3. https://www.youtube.com/watch?v=SgC-l_tgmIM
4. https://www.youtube.com/watch?v=m-6jT6CH-0M
Description of algorithms for 5 program (balances
the load on processors)
You should write a program that will contain simulations of the
distributed algorithm that balances the load on processors.

There are N identical processors working in the system.


New tasks (processes) appear on each of them, with DIFFERENT
frequency and DIFFERENT requirements (each process requires
a specific, different share of the processor's calculation power
e.g., ~3%). Simulate the following allocation strategies:

A task appears on processor x. Then:


1. (first strategy)
A processor number x asks a randomly selected processor
number y about the current load.
If it is lower than the threshold p, the process is sent there
(on processor number y).
If not, we draw and ask the next one, trying at most z
times.
If all the ones drawn are loaded above p, the process is
executed on processor number x.
2. (second strategy)
If the load of processor number x is lower than the
threshold value p – the process is executed on processor
number x. However, if this load exceeds the threshold
value p, processor x asks a randomly selected processor y
about the current load. If the load of the selected
processor y is lower than the threshold value p – the
process is executed on processor number y, otherwise, the
search for a processor is repeated until successful.
3. (third strategy)
As in the second strategy, additionally processors with a
load lower than the minimum threshold r ask (assume how
many times) randomly selected processors and if the load
of the queried one is higher than p, the queried processor
takes over some of its tasks (assume which one).
Run a simulation of strategy 1-3 for N=approx. 50÷100 and a
long series of tasks to be executed (select the parameters
yourself, so that the whole thing works 😊). In each case,
provide the following as the result:
A. Average load of processors (decide, sensibly, how it will be
calculated).
B. Average deviation from the value from point A.
C. Number of load queries and number of process migrations
(movements).

The user should be able to enter (change) the values of p, r,


z, N.

More information:
https://www.geeksforgeeks.org/multiple-processor-
scheduling-in-operating-system/?ref=lbp

You might also like