Compe 431 Sample Questions
Compe 431 Sample Questions
SAMPLE QUESTIONS:
a) Draw the Gantt chart by assuming a 0 context switching time. What is the
average waiting time and CPU utilization?
b) Assume that the context switching time is 1, repeat a).
c) Briefly discuss how the time slice should be selected to increase the
performance of the system given average CPU burst time, average I/O and
context switching time.
5. Explain briefly:
a) What is an I/O bound job?
b) What is a CPU bound job?
c) Suppose there is one I/O bound job and one CPU bound job in a ready
queue. Which one should get the processor in order to achieve a better
CPU utilization?
d) Repeat c) for a better I/O device utilization.
8.
a) Draw the Gantt chart for the given data. Use a preemptive shortest
remaining time first algorithm. Indicate clearly every preemption times.
b) Calculate the turnaround times for each process and give the average.
11. Draw the Gantt chart for CPU and I/O queues using the given table. Shortest
Remaining Time First method is used for CPU. Find average waiting time in
the ready queue. Assume FIFO is applied to the I/O queue.
If the processes enter to the ready queue at the same time because of a)
preemption, b) new submission, or c) completion of I/O, then the process of case
a) will be in front of the process in case b) which will be in front of the process of
case c)
12. Consider a priority based processor scheduling algorithm such that whenever
there is a process in the ready queue having priority higher priority than the
one executing in CPU, it will force the executing process to preempt the CPU,
and itself will grab the CPU. If there are more then one such processes having
highest priority, then among these the one that entered into the ready queue
first should be chosen. Assume that all the processes have a single CPU burst
and have no I/O operation and consider the following table:
13. Use the data given. Context switching is negligible. There is a single I/O
device using FIFO method. Draw Gantt chart for CPU and I/O device.
Calculate average turnaround time and CPU utilization for
where
tr(i) = the time where process i enters to the ready queue last time
CPU(i) = next CPU burst for process i.
tnow = current time.
15. Explain the reasons for a memory management and CPU scheduling
algorithms in a multiuser system? Can we do without them?
18. A system is using paging with four associative registers. Use the data given
below for registers and page table:
PT for user_12
Page # Frame #
0 9
1 6
2 15
3 7
4 42
Associative registers
User # Page # Frame #
12 3 7
5 2 18
12 4 42
9 0 10
PTLR(12) = 5
PTBR(12) = 50000
Page Size = 1024 words
<2,1256>
<4,572>
<0,14>
<3,290>
<5,290>
19. Given the memory map below with variable partitioning memory management
method.
J1 (50K)
Free (45K)
J2 (40K)
Free (10K)
J3 (20k)
Free (30K)
Jobs arrive/leave in the given order:
J4 (10K) arrives
J5 (20K) arrives
J6 (15K) arrives
J7 (20K) arrives
J3 leaves
J8 (50K) arrives
Draw the memory map after each step of the above job arrivals for the following
methods:
a) First – fit
b) Best – fit
c) Worst - fit
c) With the data given above calculate the min hit ratio to have an
effective memory access time of 320 nanosec.
21. Consider a system using segmentation also has the ability to share segments.
Segment numbers are fixed. To share segments a shared segment table
(SST) is needed and segment table (ST) must be modified. Assume the
system is capable of dynamic relocation but to reduce overhead it should be
used only when absolutely necessary.
ST-6
Seg # Base Size shares
0 - - 256
1 0 100 -
2 100 90 -
3 600 15 -
ST-9
Seg # Base Size shares
0 190 100 -
1 - - 256
2 290 10 -
SST
Seg # Base Size # of shares
256 400 200 2
Assume maximum number of segments per process is 256, and segments are
numbered starting with 0.
a) What should be done when a segment previously unshared, becomes a
shared segment?
b) When dynamic relocation is needed in this system?
c) Assume segment-2 of process 6 is being executed. A reference is made to
segment-0 of process 6. How is the corresponding physical address going to
be found?
d) How would self-references within shared segments be handled?
e) What is the # of shares field in SST used for?
22. In a computer system, logical addresses are 24 bits long. The machine
implements paged segmentation with a maximum segment size of 64K words
and 4K-word pages:
a) Show in detail the logical address structure. Indicate segment, page and
displacement bits.
b) How many segments can a process have?
c) If a process needs to be loaded fully into memory, what is the minimum
physical memory size?
d) If the physical memory has 65536 frames, show the physical address
structure.
e) Draw a functional block diagram for implementing paged segmentation.
Indicate the sizes of all necessary tables.
23. The following memory map is given. Assume jobs arrive in the given order.
P1
Free (30K)
P2
Free (20K)
P3
Free (50K)
P4
• P5 (16K) arrives
• P6 (40K) arrives
• P7 (20K) arrives
• P8 (14K) arrives
• P5 leaves
• P9 (30K) arrives
a) Draw memory maps after P8 arrives and after P9 arrives, using first-fit,
best-fit and worst-fit allocation methods. Assume there is no compaction.
b) Draw the same memory maps in a) and perform compaction whenever
necessary. Show the map after each compaction as well.
24. In a system that uses paging, the logical address is 20 bits long, where the
most significant 8 bits is the page number; the least 12 bits denote the offset.
Memory size is 256KByte
a) What is the page size (in bits)?
b) What is the maximum number of pages per process?
c) How many frames does the system have?
d) Give the page table structure. Assume 2 bits are used for attributes.
e) How many bits are required for each page table entry?
f) Assume the memory is increased to 1024Kbytes; recalculate c) and e).
STBR = 1000
STLR=5
Associate Registers Access Time = 50nsec
Memory Access Time = 500nsec
ST
Segment # Base Limit
0 10000 1000
1 12000 2000
2 25000 4000
3 15000 8000
4 38000 4000
AR
Segment # Base Limit
0 10000 1000
1 12000 2000
Assume that data can be written into associative registers in parallel with a memory
read or write. To replace data in associative registers LRU policy is used.
For each address, find the physical address and total time spent in calculating that
address. Indicate which memory locations are accessed during address translation.
Show all changes to associative registers.
<0, 150>
<0, 3700>
<2, 900>
<2, 3780>
<5, 200>
<1, 200>
26. Given the memory map below. Apply worst-fit algorithm and draw the final
map. Indicate if compaction is needed.
P1
Free (9K)
P2
Free (20K)
P3
Free (14K)
P4
• P5 (3K)
• P6(5K)
• P7(7K)
• P8(6K)
27. Variable partitioning is used for the memory map. Find the resulting memory
map for the jobs below using first-fit, best-fit and worst-fit algorithms. Indicate if
compaction is needed.
P1(9K)
Free (20K)
P2(11K)
Free (10K)
P3(18K)
Free (30K)
• P5 (3K)
• P6(5K)
• P7(7K)
• P8(6K)
28. A demand paging system is using associative registers
a) Assume the the hit ratio is 80%, register access time is 50nanosec and
memory access time is 950nanosec. Calculate the effective memory
access time (emat). Assume that registers can be loaded in parallel
with an access to the main memory.
b) If the probability of a page fault is 0.005, calculate effective access time
where the page fault service time is 5msec. Use emat calculated
above.
29. In a demand paging system, the working window size is 7. Given the following
reference string for process P:
1, 2, 1, 4, 3, 4, 1, 2, 1, 4, 5, 2, 5, 3, 5, 2, 3
Tnow
30. Given the following reference string below for a demand paging system which
uses FIFO page replacement algorithm:
4, 3, 2, 1, 4, 3, 5, 4, 3, 2, 1, 5
a) Assume that there are 3 memory frames. Give a picture of all pages in
memory for the reference string, after each page fault.
b) Repeat a) using 4 memory frames.
c) Comment on the total # of page faults in a) and b).
Discuss one by one if the following changes can improve the processor
utilization:
2, 4, 5, 4, 9, 2, 7, 4, 8, 9, 1, 6, 2, 2, 5, 3, 8
d) In demand paging system, why is it more desirable to replace an
unmodified page rather than a modified one?
e) When is it more desirable to replace a modified page?
36. Assume that we have an n-bit counter associated with each frame in a virtual
memory system with f frames. Assume that demand paging is used. Every
time any page is referenced by a process, a ‘1’ is shifted into the most
significant bit of the counter associated with the referenced page and zeros
are shifted into the counters of all other frames allocated to the referencing
process. The least significant bits are discarded by this operation. The lowest
numbered frame with the lowest counter value is replaced in case of a page
fault.
a) Show the frame contents after each page reference for the following
reference string, where n=2 (2 bit counters) and f=4. Assume initially all
frames are empty with counters=00. There is onşy one process.
Reference string : 4, 3, 4, 7, 2, 3, 5, 8
Frame No Content
1 4
2 8
3 3
4 5
Use OPT algorithm
Frame No Content
1 A5
2 A2
3 B3
4 B4
38. Assume a demand paging algorithm with a working window size = 4 (that is
the last 4 page references of each process constitute the windows of those
processes). Assume this working set size correctly reflects program locality
characteristics.
Time: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Ref: A3 B1 A1 A2 B3 B4 A3 A4 B2 B4 A1 A3 A1 B2
39. Equal local frame allocation policy is used in a demand paging system. A
process allocates f frames. All these f frames were initially empty. The process
has a page reference string length=s. There are exactly n distinct page
numbers in this string. Consider OPT, LRU, and FIFO algorithms.
a) If n <= f,
1. What is the min # of page faults for this process with this
reference string? Which page replacement algorithm can
achieve this number?
2. What is the max # of page faults for this process with this
reference string? Which algorithm may cause this many page
faults?
b) If n>f, repeat 1. and 2.
40. Consider a demand paging system with 3 frames in memory. Page
replacement policy is LRU, and a global replacement is done. However, it is
given that each process needs at least one page in memory for execution.
There are two processes, P1 and P2 executing in the system. Assume the
following reference string is given.
(1,4,r) (1,4,w) (1,2,r) (1,3,w) (2,1,r) (2,1,w) (2,2,r) (2,3,w) (1,4,r) (1,2,w) (1,3,r) (2,1,w)
where it means :
Find and indicate the page faults caused by this string, and after each page fault,
show the page tables for P1 and P2, indicating the values of valid/invalid and the
dirty bits. Assume both processes have 5 pages.
Initially assume that all the 3 frames are empty. Also assume that the processes
have not completed their execution at the end of the given reference string.
Is this system trashing? If yes, what is the minimum number of frames this system
should have to execute this reference string of P1 and P2 efficiently?
41. Consider a computer system which uses demand paging system. Assume the
system also has associative registers to implement the page table. Given :
time: 1 2 3 4 5 6 7 8 9 10 11 12
ref: A1 A2 B1 B2 A1 A3 B3 B1 A1 A3 B1 B4
Show the content of memory, and indicate whenever there is a page fault if
a) FIFO algorithm is used with global replacement
b) FIFO algorithm is used with local replacement with equal allocation
c) repeat a. with LRU
d) repeat b. with LRU
43. A working set demand paging algorithm with window size=4 (that is, last 4
page references of each process constitute the windows of those processes)
is to be applied on the reference string
time: 1 2 3 4 5 6 7 8 9 10 11 12
ref: A1 A2 B1 B2 A1 A3 B3 B1 A1 A3 B1 B4
44. Consider a computer system having virtual memory with paging. Assume that
the system also has the associative registers. Let:
45. In a system using working set model for frame allocation, explain what
happens if the window size is chosen
a) smaller than the proper size
b) larger than the proper size
46. For each of the following resource allocation graphs, find out and explain
whether there is a deadlock or not
a)
r1
r2
P1
P3
P2
r3
b)
P4 r3
r1
P1
r4
P2
P3
r2
c)
r1 r2
P2 P3
P1 P4
r4 r3
d)
r1
P2
P3
P1 P4
r3
r2
47. 2. A computer system has m resources of the same type and n processes
share these resources. Prove or disprove the following statement for the
system:
This system is deadlock free if sum of all maximum needs of processes is less
than m+n.
48. There are four processes which are going to share nine tape drives. Their
current and maximum number of allocation numbers are as follows :
P3
P1 r1
P2 r3
r2
P4
50. Given that all the resources are identical, they can be acquired and released
strictly one at a time, and no process ever needs more than the total
resources on the system, state whether deadlock can occur in each of the
following systems.
51.
a) What are the four conditions necessay for deadlock to appear?
b) Cinderella and the Prince are getting divorced. To divide their property,
they have agreed on the following algorithm. Every morning, each of
one may send a letter to the other's lawyer requesting one item of
property. Since it takes a day for letters to be delivered, they have
agreed that if both discover that they have requested the same item on
the same day, the next day they will send a letter cancelling the
request. Among their property is the glass shoe, their dog Woofer,
Woofer's doghouse, their canary Tweeter, Tweeter's cage and a sword.
The animals love their houses, so it has been agreed that any division
of property separating an animal from its house is invalid, requiring the
lawyers to negotiate on which items they already have should be
returned back. Unfortunately the lawyers are stubborn and never agree.
Is deadlock or starvation possible in such a scheme? Explain.
c) What happens if it has been agreed that in the case of any division of
property separating an animal from its house the whole division to start
over from scratch, instead of letting the lawyers to discuss. Explain if
starvation or deadlock possible now.
P1
P2 P3
r1
r2 r3
P4 r4
P5
a) Apply the deadlock detection algorithm and either indicate why the system is
deadlocked, or specify a safe allocation sequence.
b) If the process P2 also request 2 instances of resource r1, does the system
enter a deadlock? Why?
c) If a deadlock occurs in part a. and/or b., killing which process would resolve
the deadlock?
d) If the maximum declared needs are:
Process r1 r2 r3 r4
P1 4 0 0 0
P2 1 3 1 1
P3 0 0 2 1
P4 1 1 1 0
P5 1 0 1 1
does the current allocation given in part a constitute a safe state? Why?
53. Explain if the system in the figure is dedlocked. If not, give an execution order
of the processes which successfully terminates.
r2
P1 r1
P3
P5
P4
r4
P2
r3
54.
a) Explain if the following system is deadlocked or not?
b) For the following resource allocation graph, for deadlock detection show the
current contents of the AVAILABLE, ALLOCATION, REQUEST .
r1
r2
P1 P2 P3 P4
r3 r4 P5