Docsity

ECE391 Exam 2, Fall 2007, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE391 Exam 2, Fall 2007
Thursday, November 1st
Name:
•Be sure that your exam booklet has 14 pages.
•Write your name at the top of each page.
•This is a closed book exam.
•You are allowed two 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 40 points
Problem 2 35 points
Problem 3 25 points
Total 100 points
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download ECE391 Exam 2, Fall 2007 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

ECE391 Exam 2, Fall 2007

Thursday, November 1st

Name:

• Be sure that your exam booklet has 14 pages.

• Write your name at the top of each page.

• This is a closed book exam.

• You are allowed two 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 40 points

Problem 2 35 points

Problem 3 25 points

Total 100 points

Problem 1 (40 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): Your lab partner, Ben Bitdiddle, is at it again! This time, he has an exciting idea for redesigning

the TLB to enhance performance. Ben suggests that each TLB entry should also contain a task identifier to reduce context switching overhead. Is this a good or bad idea? Why?

Part B (5 points): Explain the differences between disabling an interrupt in software and executing CLI.

Problem 1, continued:

Part E (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 F (5 points): Define memory fragmentation. How does virtual memory help alleviate this problem?

Name: 5

Problem 1, continued:

Part G (5 points): Inodes in the new ext14 file system have an iblock with ten 32-bit pointers. The first 8 pointers

are direct pointers 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?

Part H (5 points): Suppose that a disk rotates at 6,000 RPM, so that it completes one rotation every 10 millisec-

onds. Suppose that there is one file, A, three disk-sectors long, laid out on a single track in the three contiguous sectors (178-180).

At the command line, a user executes the following command:

$ grep foo A

This causes the grep program to read from file A. grep will read one sector of data from its file, process the data for 2 milliseconds, and repeat for each block of the file. In any calculations you do, round to the nearest millisecond - in particular, only count disk-rotation times and process execution times.

How long does this command take to complete on a uniprocessor machine if the disk returns the data as soon as the read-head reaches the correct sector? (Assume that at time 0, the read-head is on the correct track at sector 180, and grep is executing on the CPU).

Name: 7

Problem 2, continued:

Problem 3 (25 points): Kernel Space Boundaries

You have decided to implement a new system call put list() in order to make copying data between user and kernel code easier. This system call copies a linked list from user space to kernel space, thus enabling you to do most of your list logic in user space and then send it to the kernel.

Each part of this problem is one step in the system call process. You must implement each of the following functions. Note that there are enough helper functions provided that you should be able to implement all of these functions completely in C. You are not required to use the exact same registers that linux uses.

/* the put list system call number */ #define LISTNUM 37

/* register structure

** this^ type exists in^ both kernel and^ user mode */ typedef struct { int eax; int ebx; int ecx; int edx; int edi; int ebp; int esp; int esi; } reg t;

/* list structure

** this^ type exists in^ both kernel and^ user mode */ struct list { struct list next; int size; / The number of bytes in the data field / void data; };

/* this function allows you to perform the x86 INT instructions in C

** exists in^ user mode */ void interrupt( char vector number);

/* Data Marshaling / / function that takes a reg t struct and puts the members into the appropriate registers

** exists in^ both kernel and^ user mode */ void put in regs( reg t (^) *registers);

/* function that puts the current value of the registers into the structure passed to it

** exists in^ both kernel and^ user mode */ void get out regs( reg t (^) *registers);

/* executes the x86 iret instruction */ void iret()

Problem 3, continued:

Part A (10 points): Write the generalized system call function.

/* returns: whatever the call it calls returns

** this^ function exists in kernel space ** Unmarshals data and^ invokes appropriate system call by switching on^ system call #/ int system call() { / Unmarshal arguements */

/* switch on system call / switch( ) / Fill this in (^) / { ... / other cases */

case : /* Fill this in (^) */

... /*other cases / } / Cleanup */

Name: 11

Problem 3, continued:

Part B (10 points): Write the function that copies the list from user space to kernel space.

/* returns: 0 and kernellist points to new list on success

** -1^ and kernellist points to null on^ failure ** (ie.^ memory copy incomplete due to^ bad pointers) ** ** this^ function exists in kernel space ** Allocates a new list^ in kernel space, returns pointer in^ kernellist argument */ int sys put list( struct list (^) *userlist, struct list (^) *kernellist) {

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

24593—Rev. 3.12—September 2006 AMD64 Technology

The fields within these table entries are described in “Page-Translation-Table Entry Fields” on

page 137. PTEs are not used in 2-Mbyte page translations.

Figure 5-25 shows the PDE.PS bit (bit 7) set to 1, indicating a 2-Mbyte physical-page translation.

Figure 5-23. 2-Mbyte PML4E—Long Mode

Figure 5-24. 2-Mbyte PDPE—Long Mode

Figure 5-25. 2-Mbyte PDE—Long Mode

5.4 Page-Translation-Table Entry Fields

The page-translation-table entries contain control and informational fields used in the management of

the virtual-memory environment. Most fields are common across all translation table entries and

modes and occupy the same bit locations. However, some fields are located in different bit positions

depending on the page translation hierarchical level, and other fields have different sizes depending on

which physical-page size, physical-address size, and operating mode are selected. Although these

fields can differ in bit position or size, their meaning is consistent across all levels of the page

translation hierarchy and in all operating modes.

63 62 52 51 32 N X

Available (^) (This is an architectural limit. A given implementation may support fewer bits.)Page-Directory-Pointer Base Address

31 12 11 9 8 7 6 5 4 3 2 1 0

Page-Directory-Pointer Base Address AVL MBZ

I G N

A

P C D

P W T

U / S

R / W

P

63 62 52 51 32 N X

Available Page-Directory Base Address (This is an architectural limit. A given implementation may support fewer bits.) 31 12 11 9 8 7 6 5 4 3 2 1 0

Page-Directory Base Address AVL MBZ

I G N

A

P C D

P W T

U / S

R / W

P

63 52 51 32 N X Available Physical Page Base Address (This is an architectural limit. A given implementation may support fewer bits.) 31 21 20 13 12 11 9 8 7 6 5 4 3 2 1 0

Physical Page Base Address Reserved, MBZ

P A T

AVL G 1 D A

P C D

P W T

U / S

R / W

P