Practical Works Operating System
Practical Works Operating System
Teachers:
Theoretical Part:
Exp. Mario Iribas –Prof. Headline
Eng. Liliana R. Pletchs Basin –Prof. Headline
Practical part:
Eng. Alberto Ristoff – 1st Aux.
Eng. Jorge Roa – 1st assistant
-1-
Operating Systems - Practical Work Booklet - Year 2005
Index
1st Part
Processes and Process Planning _ _ _ _ _ _ _ _ _ _ _ __ _ _ _ __ _ _ _ _ _ _ __ _ _ Page 3
2nd part
Blocking and InterBlocking_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _ _ Page 6
Concurrent Processes_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Page 7
3rd Part
Memory Management and Virtual Memory_ _ _ _ _ _ __ _ _ _ __ _ _ _ _ _ __ _ _ __ Page 8
-2-
Operating Systems - Practical Work Booklet - Year 2005
Goals
o Apply the concepts of process creation, states and planning policies to the resolution of
hypothetical situations.
Exercises
a) For each of the following scheduling algorithms determine the average return time and
the average waiting time.
b) Analyze the results and provide an opinion on the algorithm you would implement for
this workload.
c) FCFS
d) ROUND ROBIN (q= 2), (q=4),(q=8).
e) SJF (preemptible)
f) Compare round robin performance for different quantums.
g) Taking into account the alternation of processes produced by the RR, analyze the
consequences of having a Quantum that is too large or one that is too small.
2 . Create the Gantt chart and obtain the average return and average wait times for the following
workloads.
3 . Create the Gantt chart and obtain the average return and average wait times for the following
workloads.
-3-
Operating Systems - Practical Work Booklet - Year 2005
4 . Calculate the average wait time for the processes in the table using the Lowest Remaining
Time First (SRTF) algorithm.
5 . Using the table from the previous exercise, draw the Gantt chart for the case of a system that
uses a multi-queuing algorithm with feedback with the following queues
and assuming that: (a) processes enter the queue with the highest priority (highest
numerical value), and (b) a process in queue i moves to queue i-1 if they consume a full
quantum.
6. Suppose a system with a short-term process scheduler where the use of three
resources must be planned: 1 processor, 1 data input device and data output device.
Consider that for all three resources a non- preemptible FCFS policy is used and the degree
of multiprogramming is not regulated. The system model is as follows:
For the problem, consider that each work order arrives at a certain time, for which a process
is generated that first uses the CPU, performs data entry, processes the data (CPU), sends
the results to the output and finally uses the CPU. The following table provides the data for
six processes that must be processed by the system.
-4-
Operating Systems - Practical Work Booklet - Year 2005
b. Determine, for each process, the total waiting time and the transit time.
c. Determine, for the system, resource utilization and productivity.
d. Analyze whether resource utilization and productivity are improved if round-robin is
used with quantum equal to a unit of time (note that the previous model is modified).
7 . A Short Term planner works with a 3-queue scheme (multilevel with feedback). The queues
are numbered 1 to 3 with queue 1 having the highest priority. The scheme works as follows:
C1 : works with an SRTF + RR algorithm with Q=2. All jobs arrive in this queue.
C2 : Work with an RR Algorithm with Q = 3.
C3 . Work with a FCFS Algorithm. Once jobs arrive in this queue, they stay there until they
finish.
A job is executed in a given queue as long as there are no jobs in a higher priority queue.
The following information is available about processes that arrive at the system:
TR T. Y SIZE(MB)
A. O
U
1 0 2 3
2 2 5 7
3 3 10 10
4 6 4 2
5 7 7 17
Make the Gantt Chart and calculate the Average Return and Wait time
a) Draw Gantt charts (all with the same scale) that illustrate the execution of these
processes using the following planning schemes:
a.1 ) FCFS; a.2 ) Non-appropriative SJF; a.3 ) appropriative SJF; a.4 ) Non-
appropriative priorities; a.5 ) Appropriative priorities; a.6 ) RR with quant=1; a.7 ) RR
with quant=6;
a.8 ) Preemptive multi-level queue planning with process planning: RR system
(quant=1); interactive FCFS; FCFS lots
b) Calculate the return and waiting times for each process according to the planning
algorithms used in the previous section. Indicate which scheduling algorithm offers
the shortest average wait, return, and context switch times.
9 . Consider process planning in a system with an input/output device. Processes have bursts of
CPU usage and then proceed to execute an I/O operation. When a process executes an
input/output instruction it is taken out of the CPU scheduling queue and added to the device
queue. Processes wait for the interrupt and then return to the CPU scheduling queue. If the
device queue is not empty then the operation requested by the next process in the queue
proceeds. Assume that the device queue is scheduled with FCFS (first in first out) and that
an input/output operation takes 4 time units.
-5-
Operating Systems - Practical Work Booklet - Year 2005
a) Draw Gantt charts that illustrate CPU scheduling when using algorithm a.1 ) FCFS, a.2 )
Non-preemptive priorities and a.3 ) Preemptive priorities
b) Calculate the average return time and percentage of CPU usage for the 3 options in
item a) taking into account that the return time is the time that elapses from when a
process enters the ready queue until it leaves it. .
10 . Represent the average return time obtained by RR planning against the time quanta for
the processes: P1 duration 6, P2 duration 3, P3 duration 1 and P4 duration 7, if all are
present at the initial instant and the time quanta used They vary in the range from 1 to 7.
Calculate in each case the number of context changes produced
eleven . A certain operating system has a CPU scheduling algorithm based on multilevel
feedforward queues (3 queues). The way in which jobs are hosted in each of the queues is
as follows:
- All jobs when they arrive at the system are placed in queue 1, which is scheduled
according to a Round-Robin algorithm with a time quantum equal to 2 ms. In this queue, a
job will remain if after executing its first CPU burst, it has bursts shorter than 5ms left to
execute. Otherwise it would go to queue 2 or queue 3.
- A job will move to queue 2, if it has a CPU burst greater than or equal to 5ms to execute.
This job will remain in this queue until it finishes executing and is scheduled according to
a Round-Robin with quantum equal to 3ms.
- A job will move to queue 3, if it has a CPU burst greater than or equal to 8ms to execute.
This job will remain in this queue until it completes execution and is scheduled based on
an SJF with requisition.
Knowing that queue 1 is the highest priority and queue 3 is the lowest priority.
Given the following set of work with its corresponding arrival and execution times:
It is requested:
a) Draw on the attached graph how the jobs are located in each of the queues and
the order of execution.
-6-
Operating Systems - Practical Work Booklet - Year 2005
NOTE:
Suppose that when a job finishes its CPU burst (its quantum), it is placed in the
corresponding queue and then scheduling is performed, that is, a job is chosen from the
highest priority queue that contains some work.
-7-
Operating Systems - Practical Work Booklet - Year 2005
Goals
Exercises
1. Consider the following snapshot of a system. There are no pending requests in the
queue
a. Calculate what resources each of the processes could still request and fill in the column
(remaining demand)
b. Is the system currently in a secure or insecure state? Fundamentally.
c. Is the system currently locked? Fundamentally
d. What processes, if any, are or may become interlocked?
e. If a request for (0,1,0,0) arrives from P3, can this request be granted immediately? In
what state (interlocked, secure or insecure) would the system leave the immediate
granting of the complete request? What processes, if any, are or may become
deadlocked if the full request is granted immediately?
2. Consider a system with a total of 150 Memory Units, assigned to three processes as
follows:
Apply the Banker's algorithm to determine whether it would be safe to grant each of the
following requests. If the answer is yes, indicate the termination sequence that would make
it possible. If the answer is no, show the resulting reduction in the allocation table.
a. A fourth process arrives, with a maximum memory need of 60 and an initial need of
25 units.
b. A fourth process arrives, with a maximum memory need of 60 and an initial need of
35 units.
-8-
Operating Systems - Practical Work Booklet - Year 2005
a. Create the Assigned, Need and Maximum matrices and the Available vector.
b. Determine whether or not the following requests can be fulfilled:
- Request for (1, 0, 0, 2) by P 3 .
- Request for (1, 1, 0, 1) by P 2 .
- Request for (1, 1, 3, 1) by P 1 .
- Request for (3, 2, 0, 0) by P 0 .
c. Run the security algorithm for each of the requests and indicate the sequences of
safe states (if any)
4. Given 5 processes whose Assigned and Maximum matrices and whose Available vector
are detailed below:
5. Justify why the following resource allocation status is not consistent. Make the
corrections you consider necessary, and determine the needs matrix
2 0 0 1 1 2
A= 0 1 0 M= 1 0 0 E= [2 3 2] D= [1 0 2]
0 2 0 0 0 0
-9-
Operating Systems - Practical Work Booklet - Year 2005
Goals
Exercises
1 . Given the following Precedence Graph and the following emergence times of each Yes. The
FCFS CPU scheduling algorithm is used.
Irruption time
S1 3
S2 2
S3 1,5
S4 6
S5 3
S6 2
S7 5
S1
S2 S3 S4
S5 S6
S7
S8
requested:
a) Graph the ready and Blocked queue at the end of each Yes, if the FORK/JOIN statements
are used to model the graph.
The time it takes for the OS to execute a fork or join instruction is 0.5 microseconds. We
also assume that processes that cannot run concurrently are blocked until the event they
expect occurs.
- 10 -
Operating Systems - Practical Work Booklet - Year 2005
b) The execution of which instruction causes the passage from the blocked queue to the list
queue? Under what conditions?
c) Create the program that models this graph using the FORK/JOIN statements
d) Create the program that models this graph using the COBEGIN / COEND sentences.
2 . Given the following graphs, create the corresponding program by applying the statements:
a- COBEGIN / COEND
b- FORK/JOIN
2.1
1 8
9
2 3
1
0 1
4
4
1
1 2
1
5
6 1
3
1
5
7
1
6
- 11 -
Operating Systems - Practical Work Booklet - Year 2005
2.2 S
0
S S S
1 2 3
S
Ye
4 s
13
S
S 6
5
S S S
7 8 9
Ye
s
10
Ye
s
11
Ye
s
12
Ye
s
14
- 12 -
Operating Systems - Practical Work Booklet - Year 2005
Goals
Exercises
1 . The memory manager that uses a variable size partitioning strategy with blocks of 600 bytes,
400 bytes, 1000 bytes, 2200 bytes, 1600 bytes, and 1050 bytes.
a) Which block will be selected to satisfy a 1603-byte request using a Best-Fit policy?
b) Ditto using the Worst-fit
c) Assuming that the list is ordered as it appears in the problem statement, which block will
be selected to satisfy a request of 1603 bytes using the Best-fit policy?
2 . Let us consider a Swap system in which the memory consists of the following slot sizes in
Memory order: 10K, 4, 20, 18, 7K, 9K, 12K, 15K.
What space is chosen if segments of:
a) 12K
b) 10K
c) 9K
to). Indicate how memory allocation would be performed according to an MFT allocation
method that uses a Best-Fit algorithm. The CPU scheduling algorithm is FCFS.
b). Indicate how memory allocation would be performed according to an MVT allocation
method that uses a Best-Fit algorithm. The CPU scheduling algorithm is FCFS.
c). Indicate for both points (a and b) how much memory is wasted and what type of
Fragmentation occurs.
- 13 -
Operating Systems - Practical Work Booklet - Year 2005
4 . Given the following Table: The following are the sizes established for the jobs that
are normally executed in the computing center:
TR T.A. YOU SIZE(KB)
1 0 5 15 OPERATING SYSTEM 32K
2 0 4 20 VERY SMALL JOBS 6K
3 0 10 12 AVERAGE JOBS 20K
4 0 3 5 VERY BIG JOBS 70K
5 0 2 3
6 0 10 70
7 0 5 25
8 0 5 10
to). Indicate how memory allocation would be performed according to an MFT allocation
method that uses a Best-Fit algorithm. The CPU scheduling algorithm is Round-Robin
with Q= 4.
b). Indicate how memory allocation would be performed according to an MVT allocation
method that uses a Best-Fit algorithm. The CPU scheduling algorithm is Round Robin.
With Q=4
c). Indicate for both points (a and b) how much memory is wasted and what type of
Fragmentation occurs.
to). Indicate how memory allocation would be performed according to an MFT allocation
method that uses a Best-Fit algorithm. CPU scheduling algorithm is FCFS
b). Indicate how memory allocation would be performed according to an MVT allocation
method that uses a Best-Fit algorithm. CPU scheduling algorithm is FCFS
c). Indicate for both points (a and b) how much memory is wasted and what type of
Fragmentation occurs.
to). If a memory reference takes 1.2 microseconds, how long will a paged memory
reference take?
b). If we add 8 associative registers and 75% of all page table references are in the
associative registers, what is the effective memory reference time? (suppose finding a
page table entry in the associative records, if it is found there, takes zero time)
- 14 -
Operating Systems - Practical Work Booklet - Year 2005
9 . For an address format of P=4, and D=4, the following memory map is available:
x
x
.
x .
x .
.
15
10 . The OCM Operating System works with a virtual memory scheme with paging. Currently
the HW is Supported by 64MB of Ram Memory. The size of each page is 256KB. To
Improve the Performance of Virtual Memory, there is an advanced address translation
buffer that has 512Kb. The access time to this Buffer is low, being half the memory access
time where it is 98 Milliseconds. The percentage of hits on the buffer is 72%...of the rest
15% a page fault occurs in that case the page fault service time is 3.4 Microseconds.
The Short Term planner works with a 3-queue scheme (multilevel with feedback). The
queues are numbered 1 to 3 with queue 1 having the highest priority. The scheme works as
follows:
C1 : works with an SRTF + RR algorithm with Q=2. all jobs arrive in this queue.
C2: Work with an RR Algorithm with Q = 3.
C3 . Work with a FCFS Algorithm. Once jobs arrive in this queue, they stay there until they
finish.
A job is executed in a given queue as long as there are no jobs in a higher priority queue.
There is the following information about processes that arrive at the system:
TR T. Y SIZE(MB
- 15 -
Operating Systems - Practical Work Booklet - Year 2005
A. O )
U
1 0 2 3
2 2 5 7
3 3 10 10
4 6 4 2
5 7 7 17
It is requested:
a) Determine the number of Pages that can be in the system
b) Determine the number of bits in the address register
c) determine the number of bits of the offset
d) determine the number of bits on the page
e) determine how much memory can be dissected.
f) Find the effective memory access time. State the formula that applies.
g) Assuming that the memory is initially empty. Create the page table for each process
that is loaded into memory. Pages are always allocated starting from frame 0 onwards.
h) Mention if any type of fragmentation occurs and how much it occurs.
i) Make the Gantt Chart and find the Average Return and Wait time.
eleven . There is a virtual memory scheme that works with on-demand paging. According to the
following measurements, it is known that:
The memory access time is 2970 nanoseconds, double this being the paged memory
access time. This system works with a set of 10 associative registers whose access time is
198 nanoseconds; The percentage of hits when searching for a page in them is 82%, of the
rest, 7.5% cause page failure, in which case the page failure service time is 2
microseconds. Calculate effective memory access time
12. Consider the following sequence of memory references for a 460-word program:
10-11-104-170-73-309-185-245-246-434-458-364
a) Indicate the reference chain assuming a page size of 100 words
b) Calculate the page fault rate for this reference chain, assuming that the program has
a 200-word memory and a FIFO replacement algorithm.
c) What would be the page fault rate, if we used an LRU replacement algorithm?
d) What is the page fault rate for the optimal replacement algorithm?
14 . There is a Paged Virtual Memory scheme which works with 16-bit addresses, with the size
of each page being 1 KB.
At time t the CPU generates the relative address 1502.
Reply:
a. How many Bits are needed for displacement?
b. How many Bits are needed for the page number.
c. What is the number of pages possible to address?
d. From the following page table associated with a process that has 6 pages assigned,
obtain the physical address corresponding to the relative address 1502
page frame
000000 000100
000001 000111
000010 000101
000011 000001
- 16 -
Operating Systems - Practical Work Booklet - Year 2005
000100 000010
000101 000011
fifteen . A process that has 4 page frames assigned to it. The status of your table is as follows:
A failure has occurred on virtual page 4. Which framework will replace your content for each
of the following memory management policies? Support your answers.
a. FIFO
b. LRU
c. OPT
d. N.R.U.
e. Given the memory state above, immediately before the page fault, consider the
following series of references to virtual pages
4, 0, 0, 0, 2, 4, 2, 1, 0, 3, 2
How many page faults will occur if the working set policy is used with a window size of
four instead of fixed allocation? Show yourself clearly when a page fault occurs.
16 . Assume that the page table for the current process looks like the one in the figure. All
numbers are decimal, numbering always starts from zero, and all memory addresses are
byte addresses. The page size is 1024 bytes.
a) 999
b) 2121
c) 5400
17 . A computer has four page frames. The loading time, last access time, and R and M bits for
each page appear in the table below (times are measured by clock ticks).
- 17 -
Operating Systems - Practical Work Booklet - Year 2005
19 . A computer has a cache, main memory, and a disk used for virtual memory. If a referenced
word is in the cache, it takes 20ns to access it. If it is in main memory but not in the cache, it
takes 60 ns to load it into the cache, and then the reference starts again. If the word is not in
main memory, it takes 12ms to load the word from disk, followed by 60ns to copy it to the
cache, and then the reference starts again. The cache hit rate is 0.9 and the main memory
hit rate is 0.6. What is the average time, in nanoseconds, required to access a referenced
word in this system?
twenty . Let be a paged virtual memory system with 32-bit logical addresses providing a virtual
space of 220 pages and with a physical memory of 32 MBytes. What will be the size of the
page? What will be the maximum size of the page table if each entry in it occupies 32 bits?
twenty-one . If a computer works with 16-bit addresses, and has pages of size 2Kbytes
a) What size of virtual memory can we address?
b) How many pages will the Virtual memory have?
c) What will be the size of the page frame?
d) Assuming that the physical memory is 8Kbytes, how many frames will we have?
e) How many bits of the virtual memory address are used to select entries in the page
table if the page table is single level?
f) What will we use the remaining bits of the virtual memory address for?
g) How many entries will the page table have?
22 . A computer has a cache, main memory and a disk used as virtual memory. If a word is in
the cache, A ns is required to access it, if it is in main memory B ns to load it into the cache
and start again. If the word is not in main memory, C ns are required to bring it from disk,
followed by B ns to bring it to the cache. If the cache hit rate is (n-1)/n and the main memory
is (m-1)/m. What is average access time?
2. 3 . For each of the memory management techniques that appear in the table, indicate with a
cross if it has the characteristic indicated in the column:
- 18 -