Docsity

ECE398SSL Exam 2, Spring 2005: Memory Management, Finite Automata, TLBs, and Scheduling, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE398SSL Exam 2, Spring 2005
Thursday 7 April
Name:
๎˜€
Be sure that your exam booklet has 12 pages.
๎˜€
Write your name at the top of each page.
๎˜€
This is a closed book exam.
๎˜€
You are allowed two
๎˜๎˜ƒ๎˜‚๎˜…๎˜„๎˜‡๎˜†๎˜‰๎˜ˆ๎˜Š๎˜ˆ
"sheets of notes.
๎˜€
Absolutely no interaction between students is allowed.
๎˜€
Show all of your work.
๎˜€
Challenge questions are marked with ***
๎˜€
Donโ€™t panic, and good luck!
Problem 1 20 points
Problem 2 20 points
Problem 3 20 points
Problem 4 20 points
Problem 5 20 points
Total 100 points
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download ECE398SSL Exam 2, Spring 2005: Memory Management, Finite Automata, TLBs, and Scheduling and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

ECE398SSL Exam 2, Spring 2005

Thursday 7 April

Name:

Be sure that your exam booklet has 12 pages.

Write your name at the top of each page.

This is a closed book exam.

You are allowed two

" sheets of notes.

Absolutely no interaction between students is allowed.

Show all of your work.

Challenge questions are marked with ***

Donโ€™t panic, and good luck!

Problem 1 20 points

Problem 2 20 points

Problem 3 20 points

Problem 4 20 points

Problem 5 20 points

Total 100 points

Problem 1 (20 points): Short Answers

Please answer concisely. If you find yourself writing more than a few sentences, your answer is probably wrong.

Part A (5 points): Describe one advantage and one disadvantage of using a 4-MB page size rather than a 4-kB

page size to support paging.

Part B (5 points): Given that regions (vm area structs) corresponding to kernel pages are not part of a

programโ€™s mm struct description, why must the user/supervisor (U/S) bit be set to Supervisor in page table entries

(PTEs) corresponding to kernel pages?

Problem 2 (20 points): Linux Memory Management

As you may recall, Linux manages physical page allocation using linked lists of contiguous pages. Ten lists are

kept, with the first containing single free pages, the second containing blocks of two consecutive free pages, the third

containing blocks of four consecutive free pages, and so forth. Bitmaps pertaining to free blocks are also maintained,

but are ignored by this problem in the interest of simplicity.

For this problem, you must write an allocation routine that uses the array of lists to locate an appropriate set of free

pages and reorganizes the lists as necessary.

Your routine should work as follows. When a request for  pages comes in, the routine first checks for free blocks in

the th list. If a block is found, the routine removes it from the list of free blocks and returns it. If the list is empty, the

routine checks the  th list. If a block is found in this list, the routine removes it from the list, splits it into two

blocks of  pages, places one of the resulting blocks into the  th list, and returns the other. The routine continues to

check larger lists until it either reaches the last (tenth) or finds a block that it can allocate. If the last list is empty, the

routine returns NULL.

The page allocation routine has the following signature:

block t* alloc pages (uint32 t order);

The order parameter is the log base 2 of the number of pages being requested. For example, if a caller wants 16

pages, it passes the value 4. The routine should return a pointer to the block (the first page in the block), or NULL on

failure.

You do not have to include synchronization in your code.

Data structures and the array of lists declaration are shown below. The block t structure is used to store the โ€œnextโ€

pointer for the linked list of free blocks in the first four bytes of each block. You must calculate addresses by hand by

converting pointers to integers and back. For example,

uint32 t baddr = (uint32 t)blk[0];

puts the address of the first block in the order 0 free list into the integer baddr. The figure at the bottom of this page

illustrates the data structures for the first three lists (the small boxes are the four-byte link pointers stored within the

page blocks).

Write your routine on the following page.

typedef struct block t block t; struct block t block t* next; ;

/* Array of lists of blocks. / block t blk[10];

array of free lists

Problem 2, continued:

block t* alloc pages (uint32 t order)

// Write your code here.

Problem 3, continued:

B

D E

F

A C

1/โˆ’ 2/โˆ’

3/X

0/โˆ’

2/โˆ’ 0,1,2,3/โˆ’

1/โˆ’

3/Y

1,2,3/โˆ’

Part C (12 points): Using the technique that you used for the mouse driver in MP2, produce an equivalent

deterministic finite automaton (DFA).

Problem 4 (20 points): Software-reloaded TLBs

A new ISA uses the same instruction set as the x86 ISA, but uses software to reload translation lookaside buffers

(TLBs) so as to allow operating systems to define their own page table structures. In this problem, you will examine

the routine executed when a TLB miss occurs and answer some questions about the data structures and approach taken.

The eight-byte TLB structures used by the processor

are shown to the right; these structures are mapped into

the processorโ€™s physical address space. A special reg-

ister (TLBR) then holds the physical memory address

of an array of 32 such structures, and is used by the

TLB MISS routine to add an appropriate translation

when a miss occurs. The โ€œused for translationโ€ bit is

set by the processor whenever a TLB is used to trans-

late a virtual address.

31 12 11 10

for OS use

for OS use 20โˆ’bit physical page address

20โˆ’bit virtual page address

set by processor)

(cleared by OS,

used for translation

For simplicity, the operating system defined for this problem does not swap pages out of physical memory. Pages are

thus either present in memory or not defined, and the TLB MISS routine does not need to initiate disk transfers or

other such activities.

The calling convention for the TLB MISS routine is defined as follows. All registers other than ESP and EBP are

caller-saved, so no registers need be protected. All addresses used by the TLB MISS routine are physical addresses,

thus the processor never takes a TLB miss while executing this routine (and it need not be reentrant). On entry to

the TLB MISS routine, EAX holds the virtual address to be translated. On return from the function, EAX is 0 if the

address is not mapped (no swapping!), or EAX is 1 if the address is mapped, in which case some TLB has also been

loaded with the necessary translation.

The code appears on the following page.

Part A (10 points): Based on the first loop and the last section of the code, name the type of data structure used to

hold the page table mappings and draw a picture of the data structures involved, showing all relevant sizes and briefly

describing the meaning of each field. Note that the second loop does not change the value of ESI found by the first

loop; also note that EBX points to the TLB array after exiting the second loop.

Problem 4, continued:

Part B (2 points): Calculate the number of bytes necessary to store the page tables in the manner assumed by this

code for a task with  pages.

Part C (3 points): Under what conditions might this approach still save space relative to the page table structures

defined by the x86 ISA?

Part D*** (5 points): Explain the purpose of the routineโ€™s second loop and how it achieves this purpose.

Problem 5 (20 points): Scheduling

The figure below illustrates the scheduling decisions made by the Linux scheduler as a function of time (from left to

right). The tick marks below the line denote timer interrupts. Three tasks share the processor, and are represented

as light, medium, and dark bars above the time line. None of these three tasks is the idle task. The black sections

represent interrupt handlers executed in response to either for the timer ticks or to device interrupts. Finally, the letters

above the line represent events or points in time to which the questions refer.

A B C D E F

Assume that the tasks have different priorities as follows:

Task 1, the dark task, has the highest priority

Task 2, the medium task, has the middle priority

Task 3, the light task, has the lowest priority

Part A (3 points): Which task or tasks are runnable at point A on the timeline?

Part B (4 points): What happened as a result of the timer interrupt at point B on the timeline?

Part C (2 points): What happened as a result of the device interrupt at point C on the timeline?

Part D (3 points): What happened at point D on the timeline?

Part E (3 points): Point E on the timeline represents a device interrupt that makes task 1 runnable. Why does the

scheduler continue to execute task 2 despite the fact that task 1 has higher priority?

Part F (2 points): What happened at point F on the timeline?

Part G (3 points): If possible, state the length of each taskโ€™s time quantum in ticks.