CSCI-375 SAMPLE PROBLEM

Transcription

CSCI-375 SAMPLE PROBLEM
CSCI-375 SAMPLE PROBLEM
1.
A process contains 8 virtual pages on disk and is assigned a fixed allocation of page
frames in main memory. The following page trace occurs:
1, 0, 2, 2, 1, 7, 6, 7, 0, 1, 2, 0, 3, 0, 4, 5, 1, 5, 2, 4, 5, 6, 7, 6, 7, 2, 4, 2, 7, 3, 3, 2, 3
Show the successive pages residing in the 4 frames using LRU, FIFO, LFU and
OPT policies. Compute the miss ratio in main memory. Assuming the frames are
initially empty.
2.
Given the following reference string:
0
a)
b)
c)
d)
3.
4.
1
2
3
0
1
2
3
0
1
2
3
4
5
6
7
Determine the number of page faults with the working set algorithm  =3
Determine the number of page faults with the working set algorithm  = 4
Determine the number of page faults with the working set algorithm  = 9
Which value of  is optimal for this reference string? Why?
Considering the following 5 processes. P1 arrives at time 0, requires 3 units of time to
finish. P2 arrives at time 4, requires 6 units of time. P3 arrives at time 5, requires 3
units of time. P4 arrives at time 6, requires 5 units of time. P5 arrives at time 9,
requires 2 units of time.
a) Draw the Gnatt charts to illustrate the execution of these processes using the
following scheduling algorithms: FCFS, non-preemptive SJF, preemptive SJF,
RR(q=1), RR(q=4), Feedback (q=1) and feedback (q=2i), respectively.
b) What is the turnaround time of each process for each scheduling algorithm?
Recall the Banker’s Algorithm for deadlock avoidance. Consider the following
snapshot of a system in which Pi’s are processes and Ri’s are resource types.
Allocation
R0 R1 R2 R3
Max
Available
R0 R1 R2 R3 R0 R1 R2 R3
P0
P1
P2
P3
P4
1
0
5
3
1
0
1
1
0
0
0
0
3
6
0
2
0
4
2
4
0
1
2
0
0
0
7
3
6
6
1
5
5
5
5
2
0
6
2
6
1 5 2 0
a) Explain what are Allocation, Max, and Available
b) What is the context of the matrix Need? Explain what Need is?
c) Is the system in a safe state? Justify your answer and show all your work
5.
Apply the deadlock detection algorithm to the following data and show the results:
Available=
Request = R1
P1 2
P2 1
P3 2
6.
R2 R3 R4
0 0 1
0 1 0
1 0 0
Allocation =
P1
P2
P3
R1
0
2
0
R2 R3 R4
0 1 0
0 0 1
1 2 0
Consider the following memory architecture using paging technique with 2-level page
tables (Memory addressing is in terms of bytes.)
Physical Memory Address Width 20 bit
Logical Address Width
24 bit
Page/Frame size in bytes
64 bytes
Calculate the following:
a) The number of bits to represent the offset within a page.
b) The maximum number of pages each process can access in logical address
space and the maximum number of frames in physical memory.
c) If the outermost page table has 32 entries, how many bits are needed in the
logical address to represent the outer page table? How many bits are needed in
the logical address in order to represent the inner page table?
7.
Consider a paging system with the page table stored in memory.
1) If a memory reference takes 200ns, how long does a paged memory reference
take?
2) If we add TLBs, and 60% of all page-table references are found in the TLBs, what
is the effective memory reference time? Assume that TLB access take 0.3 ns.
3) If the page fault rate is 1%, and the time to deal with page fault after a page fault
is found is 10000ns, what is the effective memory reference time?
8.
What are the two operations on a semaphore? Write (in pseudocode) the two
operations on a semaphore. Give an example of a simple situation illustrating that if
these operations are not executed atomically, mutual exclusion may not be enforced.
9.
What are the difference between process and thread?
10.
What are the five major activities of an operating system with regard to process
management?