Uploaded by ruydoan72

Sample CS444 Final Exam, Fall 2009

advertisement
Name: ________________________________________________
University of Massachusetts - Boston
Intro to Operating Systems
Dr. Ronald Cheung
CS 444 - Fall 2009
In-Class, Open Book Final Examination
December 21, 2009
The work on this examination is to be your own and you are expected to adhere to the UMass-Boston honor system. All questions can
be answered by either circling the correct answer(s) or by one or two short sentences. In the latter case, brevity counts. Do not try to
make up for a lack of understanding by providing a rambling answer.
1.
(3 points) What is the major use of CR2?
2.
(3 points) Why does the TLB have to be flushed
when switching between processes?
3.
6.
(3 points)What is the difference between
segmentation and paging?
7.
(6 points) When executing the following
instruction, multiple page faults can occur.
…
0010: mov 4(R1), R2 where R1 has an address
…
Name the possible places:
(3 points) What is the major cause for deadlocks?
1._______________________________________
2._______________________________________
4.
(3 points) What is priority inversion?
8.
(6 points) Circle one that is most appropriate.
a) (T/F) Interrupts can occur in a system call
service routine. If true, how?
5.
(3 points) What is memory pinning?
b) (T/F) System calls can occur in an interrupt
service routine. If true, how?
1 out of 4
Name: ________________________________________________
University of Massachusetts - Boston
Intro to Operating Systems
9.
Dr. Ronald Cheung
CS 444 - Fall 2009
(20 points) Adding a clock policy helps to reduce the number of page faults for the First-In-First-Out
(FIFO) page replacement algorithm. The clock policy makes use of the referenced bit. When a page is first
loaded into a frame in memory, the referenced bit is set to a 1(denoted by * ). If the page is subsequently
referenced, its referenced bit is set to 1. The set of pages are considered to be in a circular buffer. When a
page is replaced, the pointer points to the next page in the circular buffer.
To decide which page to replace, the operating system looks for a page with the referenced bit =0. Each
time when it encounters a page with referenced bit =1, it sets the bit =0 and skips it, and look for another
page with bit =0. If all the pages have referenced bit =1, the pointer will make 1 complete circle through the
buffer, setting all the bits =0, and replace the page in the original position. The pointer then points to the
next page in the buffer.
Fill in the pages in memory using the above page replacement algorithm. Update the arrow which points to
the next page buffer. Page number n with * indicates the referenced bit of page n is equal to 1. Page number
n with no * means referenced bit =0. Ask questions if you need clarifications.
Page
Reference
String
2
3
2
1
5
2*
2*
2*
2*
5*
3*
3*
3*
3
1*
1
Pages in
memory
Page faults
P
P
P
2
4
5
P
How many page faults will occur for this page reference string?
________________________________
2 out of 4
3
2
5
2
University of Massachusetts - Boston
Intro to Operating Systems
10.
Dr. Ronald Cheung
CS 444 - Fall 2009
(20 points) Suppose the page table for the process currently executing on the processor looks like the
following. All numbers are decimal and addresses are memory byte addresses. The page size is 1024 bytes.
virtual page number(vpn)
0
1
2
3
4
5
valid bit
1
1
0
1
0
1
Referenced bit Modified bit Page Frame Number
1
0
4
1
1
7
0
0
-0
0
2
0
0
-0
1
0
a. (15 points) What physical addresses, if any, would the following virtual addresses correspond to?
i)
1052
_________________
ii)
2221
_________________
iii)
5499
_________________
b. (5 points) If a page fault occurs, which page is most likely to be evicted based on the LRU algorithm?
_____________________
3 out of 4
University of Massachusetts - Boston
Intro to Operating Systems
Dr. Ronald Cheung
CS 444 - Fall 2009
11. (30 points) In hw5, you learned how to write a pre-emptive scheduler. The logic to decide on what next
process to run assumes all processes are of equal priority. What do you have to do to make the scheduler to be
pre-emptive priority based? Show your code modifications on the data structures and the scheduler program.
4 out of 4
University of Massachusetts - Boston
Intro to Operating Systems
Dr. Ronald Cheung
CS 444 - Fall 2009
Answers to Final Exam:
1.
register that stores where page fault occurs.
2.
Flushing the TLB will get rid of the PTE cached for the previous process.
3.
Sharing of resources between processes.
4.
Higher priority tasks cannot preempt lower priority tasks and has to wait for the lower priority one to finish.
5.
Locking pages in memory.
6.
Segmentation has multiple linear addresses whereas the paging only deals with one.
7.
1. accessing address at 0x0010
2. accessing data memory at 4(R1)
8.
T: Interrupts can occur in the middle of system call routines (IF not set=0).
F: System calls don’t happen in interrupt service routine because ISR is already running in the kernel mode
and system calls happen in user mode .
9.
Page Reference String
2
3
2
1
5
2
4
5
3
2
5
2
2*
2*
2*
2*
5*
5*
5*
5*
3*
3*
3*
3*
3*
3*
3*
3
2*
2*
2*
2
2*
2
2*
1*
1
1
4*
4*
4
4
5*
5*
Pointer
to next
reference
Page faults
P
P
P
P
P
P
The number of faults for this page reference string= 8
10. a)
i) VA:1052  PA: 7168 +28=7196
ii) VA: 2221  PA: not valid
iii) VA: 5499  PA: 0 + 379 = 379
b) Virtual page number 3 is most likely to be evicted based on the LRU.
11.
1) In the PEntry array, add a parameter called int p_priority(1,2,...,MAX_PRI)
2) The code for the scheduler, in deciding which process to run, looks like:
/* check priority and process status starting with the highest priority*/
for(j=MAX_PRI, found =0; j > 0 && found ==0; j--){
5 out of 4
P
P
Pages in
memory
University of Massachusetts - Boston
Intro to Operating Systems
Dr. Ronald Cheung
CS 444 - Fall 2009
for(i=1;i<NPROC-1;i++){
if (proctab[i].p_status == RUN && proctab[i].p_priority == j){
curproc=&proctab[i]; /* chosen to run */
found =1;
break;
}
}
}
/* if all user processes are blocked, use process0 */
if(found ==0){
curproc= &proctab[0];
}
6 out of 4
Download