Vous êtes sur la page 1sur 7

CS385 Operating Systems - PRACTICE Midterm

Please write your name on the top of every page. Give your answer to each question in the space provided below
the question. If more space is needed, use the reverse side of the sheet, and indicate clearly which question you are
answering.

Your name:
Your signature:

The exam has 5 questions, for a total of 100 points.


Question:

Total

Points:

16

24

28

16

16

100

Score:

CS385 Practice Midterm

Name:

1. Define the following terms


(a) (4 points) Thrashing

(b) (4 points) TLB

(c) (4 points) Principle of Locality

(d) (4 points) Virtual Address

Points earned:

out of a possible 0 points

CS385 Practice Midterm

Name:

2. Short Essay. Answer these questions in one paragraph, between two and eight sentences.
(a) (6 points) In a kernel with a layered structure, which layers can a given layer send commands to?

(b) (6 points) Why do we want the working set to be a subset of the resident set?

(c) (6 points) Assuming all jobs arrive at the same time, why is Shortest Job Next optimal?

(d) (6 points) What kind of fragmentation do pages eliminate, and how?

Points earned:

out of a possible 0 points

CS385 Practice Midterm

Name:

3. Scheduling. Assume the following jobs. For each scheduling algorithm, list which job will be run at each time
step, and give the average turn around time.

A
B
C
D

Arrival Time
0
4
6
7

Service Time
8
5
2
1

(a) (6 points) FIFO


0

10

11

12

13

14

15

16

17

18

19

20

10

11

12

13

14

15

16

17

18

19

20

(b) (6 points) Round Robin


0

Points earned:

out of a possible 0 points

CS385 Practice Midterm

Name:

(c) (8 points) Shortest Process Next (non-preemptive)


0

10

11

12

13

14

15

16

17

18

19

20

12

13

14

15

16

17

18

19

20

(d) (8 points) Shortest Remaning Time (preemptive)


0

10

11

Points earned:

out of a possible 0 points

CS385 Practice Midterm

Name:

4. Sizing the Segment Table.


(a) (16 points) Assume you have addresses with 5 bits for the segment number, and 27 bits for the offset. You
have a 1 GB of physical memory. Based on the given information, fill in the number of entries, size of base
and bound fields, size of the entry, and total size of the segment table.

Points earned:

out of a possible 0 points

CS385 Practice Midterm

Name:

5. xv6 implementation
(a) (16 points) Please provide both a high-level summary and a line-by-line description of what this code is
doing. For the practice midterm, you may use your xv6 booklet - on the real midterm, you will be provided
with the relevant pages from the booklet to reference.
int
fork ( void )
{
i n t i , pid ;
s t r u c t p r o c np ;
/ / Allocate process .
i f ( ( np = a l l o c p r o c ( ) ) == 0 )
r e t u r n 1;
/ / Copy p r o c e s s s t a t e from p .
i f ( ( np>p g d i r = copyuvm ( p r o c >p g d i r , p r o c >s z ) ) == 0 ) {
k f r e e ( np>k s t a c k ) ;
np>k s t a c k = 0 ;
np> s t a t e = UNUSED;
r e t u r n 1;
}
np>s z = p r o c >s z ;
np>p a r e n t = p r o c ;
np> t f = p r o c > t f ;
/ / C l e a r %e a x s o t h a t f o r k r e t u r n s 0 i n t h e c h i l d .
np>t f >e a x = 0 ;
f o r ( i = 0 ; i < NOFILE ; i ++)
i f ( p r o c > o f i l e [ i ] )
np> o f i l e [ i ] = f i l e d u p ( p r o c > o f i l e [ i ] ) ;
np>cwd = i d u p ( p r o c >cwd ) ;
s a f e s t r c p y ( np>name , p r o c >name , s i z e o f ( p r o c >name ) ) ;
p i d = np>p i d ;
/ / l o c k t o f o r c e t h e c o m p i l e r t o e m i t t h e np> s t a t e w r i t e l a s t .
a c q u i r e (& p t a b l e . l o c k ) ;
np> s t a t e = RUNNABLE;
r e l e a s e (& p t a b l e . l o c k ) ;
r e t u r n pid ;
}

Points earned:

out of a possible 0 points