Docsity

Exam 3 Problems - Computer Systems Engineering | ECE 391, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE391 Exam 3, Fall 2008
Thursday, November 13th
Name:
•Be sure that your exam booklet has 15 pages.
•Write your name at the top of each page.
•This is a closed book exam.
•You are allowed three 8.5×11"sheets of notes.
•Absolutely no interaction between students is allowed.
•Show all of your work.
•Don’t panic, and good luck!
Problem 1 12 points
Problem 2 13 points
Problem 3 10 points
Problem 4 15 points
Problem 5 20 points
Problem 6 30 points
Total 100 points
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Exam 3 Problems - Computer Systems Engineering | ECE 391 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

ECE391 Exam 3, Fall 2008

Thursday, November 13th

Name:

• Be sure that your exam booklet has 15 pages.

• Write your name at the top of each page.

• This is a closed book exam.

• You are allowed three 8. 5 × 11 " sheets of notes.

• Absolutely no interaction between students is allowed.

• Show all of your work.

• Don’t panic, and good luck!

Problem 1 12 points

Problem 2 13 points

Problem 3 10 points

Problem 4 15 points

Problem 5 20 points

Problem 6 30 points

Total 100 points

Problem 1 (12 points): Short Answers

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

Part A (6 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 (6 points): A computer with a 32-bit address uses a two-level page table. Virtual addresses are split into a

12-bit top level field, an 8-bit second level page table field, and an offset. How large are the pages, and how many are there in this address space?

Problem 3 (10 points): Short Answer

Inodes in the new ext14 file system have an iblock with ten 32-bit pointers. The first 8 pointers are direct point- ers to blocks, the ninth pointer is a single indirect pointer, the tenth pointer is double indirect. Assuming 2048 byte blocks, what is the largest file size supported by the ext14 file system? Also, what is the largest supported disk size?

Name: 5

Problem 4 (15 points): Device Driver Design

You are developing a driver for a sound card. The device has a set of memory-mapped control registers and a single audio channel for playback. When playing audio, the device asserts its interrupt line when its internal hardware playback buffer is more than half empty. The card supports multiple audio input formats in hardware, such as 8-bit and 16-bit sound samples, various audio encodings and sample rates. The driver buffers audio data in the kernel in non-swappable memory, then transfers it to the device.

Part A (3 points): What Linux character driver interface functions ( e.g. , llseek, read, write, readdir, poll, ioctl,

mmap, open, flush, release, fsync, lock, check flags...) should be used for each of the following operations? Briefly explain your choices.

  1. Changing the audio input format:
  2. Transferring data to the driver for playback:
  3. Blocking until all audio has finished playing:

Part B (6 points): After the previous work you decide that the sound card driver requires a custom interface

instead of using the unified (open, lock, flush) file operations. Give one advantage and on disadvantage to this approach.

Name: 7

Problem 5 (20 points): Filesystems and Disk Access

This question will demonstrate your understanding of disk access policy on system performance. Supoose that a disk rotates at 6,000 RPM, so that it completes one rotation every 10 milliseconds. There are 1,000 sectors per track. Suppose that there are two files, A and B, each three disk-sectors long, laid out on a single track in the six contiguous sectors (178-183) as shown in the figure.

10 ms

178

183

179 180 181 182

B A B A B A

For simplicity, assume that a disk sector can be read instantaneously once the disk read-head is positioned correctly, and that operating system functions also execute instantaneously. There are two processes running concurrently, pro- cess 1 and process 2. The scheduler starts process 1 first.

void process_1(void) { int i;

for (i=0; i<3; i++) { read(fileA, sizeof(sector)) ... processing... ... } }

void process_2(void) { int i;

for (i=0; i<3; i++) { read(fileB, sizeof(sector)) ... processing... ... } }

Each process will read one sector of data from its file, process the data for 3 milliseconds, and repeat for each block of the file. The scheduler will optimize disk access so as to minimize the CPU’s idle state. In any calculations you do, round to the nearest millisecond - in particular, only count disk-rotation times and process execution times. For parts A-C mark an arrow with the sector number when the harddrive retrieves a sector, and mark an arrow with the sector number when the CPU finishes processing a sector.

Problem 5, continued:

Part A (6 points): How long does this command take to complete on a uniprocessor machine if the operating

system performs disk accesses in the order they are requested (FIFO) and the disk returns the data as soon as the read-head reaches the correct sector? Complete the graph below. The first CPU and harddrive operations have been done for you. (Assume that at time 0, the read-head is on the correct track at sector 180, grep is executing on the CPU, and processes only sleep when they attempt to access a disk block not already in memory).

CPU:

Disk: (^6) A 0

A 0 (13)

Part B (6 points): How long does this command take to complete on the same machine if the operating system

sorts IO accesses by sector, making disk requests in order of increasing sector number?

CPU:

Disk:

Problem 6 (30 points): Virtual Memory: Page Tables

In this problem you will demonstrate your mastery of Page Table manipulation. We have attached to this exam two pages from the AMD-64 System Programming guide containing a diagram of virtual-to-physical address translation on a 64-bit processor with 2-Megabyte page frames and a 3-level page table system. The terminology used is slightly different from what you have seen in class, but the diagrams should be clear.

Notice that virtual addresses are 48-bits long, and that tables in the Page Table hierarchy contain 512 64-bit entries; the tables are still 4 kilobytes, but you index into them with 9 bits of the virtual address. As indicated in the diagrams, only the low 52 bits of the 64-bit page table entries are meaningful (ignore the NX bit).

Below, write the C function find pte. find pte takes two arguments: a copy of the 64-bit CR3 register, which points to the root of the Page Table Hierarchy; and a virtual address. find pte should return a pointer to the page table entry corresponding to that virtual address’s page (a pointer to a PDE, in the terminology of the provided documentation). If the corresponding Page-Directory-Pointer-Table or Page-Directory-Table do not exist, your find pte should invoke the get page function to allocate it. ( Hint: You may want to save time by making a helper function to retrieve the approprate bits from an integer.)

/* allocates and returns a page (4 Kilobytes) of memory. Never fails. (^) */ extern void (^) * get page();

/* turn a pointer to a page-directory-pointer-table

** into^ a page-map-level-4 entry */ extern uint64 t make pml4e( void (^) *);

/* turn a pointer to a page-directory--table

** into^ a page-directory-pointer-table entry */ extern uint64 t make pdpe( void (^) *);

Name: 11

Problem 6, continued:

uint64 t (^) *find pte( uint64 t (^) *pdbr, uint64 t vaddr){

Name: 13

AMD64 Technology 24593—Rev. 3.12—September 2006

5.3.4 2-Mbyte Page Translation

In long mode, 2-Mbyte physical-page translation is performed by dividing the 48-bit virtual address

into four fields. Each field is used as an index into a three-level page-translation hierarchy. The virtual-

address fields are described as follows, and are shown in Figure 5-22 on page 136:

 Bits 63–48 are a sign extension of bit 47 as required for canonical address forms.

 Bits 47–39 index into the 512-entry page-map level-4 table.

 Bits 38–30 index into the 512-entry page-directory-pointer table.

 Bits 29–21 index into the 512-entry page-directory table.

 Bits 20–0 provide the byte offset into the physical page.

Figure 5-22. 2-Mbyte Page Translation—Long Mode

Figures 5-23 through 5-25 on page 137 show the long-mode 2-Mbyte translation-table formats (the

formats are identical to those used for 4-Kbyte page translations and are repeated here for clarity):

 Figure 5-23 on page 137 shows the PML4E (page-map level-4 entry) format.

 Figure 5-24 on page 137 shows the PDPE (page-directory-pointer entry) format.

 Figure 5-25 on page 137 shows the PDE (page-directory entry) format.

Virtual Address

Sign Extend^ Page Offset

Page-Map Level-4 Table Offset (PML4)

Page-Directory- Pointer Offset

Page-Directory Offset

63 48 47 3938 3029 2120 0

Physical Address PDE

PDPE PML4E

9 9 9

52*

52*

52*

Page-Map Level- Table

Page- Directory- Pointer Table

Page- Directory Table

2 Mbyte Physical Page

CR

Page-Map Level-

51 12

*This is an architectural limit. A given processor implementation may support fewer bits.

21

Base Address