Docsity

ECE 398SSL Exam 2 Fall 2004, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 398SSL Exam 2 Fall 2004
Thursday, November 11th, 2004
Name:
• Be sure that your exam booklet has 11 pages.
• Write your name at the top of each page.
• This is a closed book exam.
• You are allowed two 8.5 x 11ā€ sheets of handwritten 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 ECE 398SSL Exam 2 Fall 2004 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

ECE 398SSL Exam 2 Fall 2004

Thursday, November 11th^ , 2004

Name:

• Be sure that your exam booklet has 11 pages.

• Write your name at the top of each page.

• This is a closed book exam.

• You are allowed two 8.5 x 11ā€ sheets of handwritten 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

Answer the following questions concisely. You should not need to write more than a sentence or two; if

you are writing more, it is probably wrong.

Part A (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?

Part B (5 points): Describe a benefit of using linked lists of handlers (actions) to support interrupt

chaining relative to chaining the code for the handlers together directly with JMP instructions. Also

describe one drawback of chaining (regardless of implementation).

Part C (5 points): Why must a processor flush its translation lookaside buffers (TLBs) when the

operating system allows a different program to execute?

Part D (5 points): Explain the steps necessary for a generic system call such as read (sys_read) to

reach a device-specific read function.

Problem 2, continued:

int find_unmapped_area (map* m, unsigned long len, unsigned long* where) {

Problem 3 (20 points): Designing Tests for a Device Driver

Design a complete set of tests for the Imail write message function, the code for which is provided for

you below.

Recall that this function is called as a result of an ioctl command. The ioctl provides a pointer to a

structure with a recipient’s name and a header for the message. Copies of the full Imail code are

available for your perusal, should you need them, but should not be critical to your ability to answer this

question. As an example, your answer should include the following test description:

Try to write a message to a non-existent Imail recipient; should return ENOENT.

static int Imail_write_msg (struct file* f, void* arg) { Imail_header_t header; /* header for new message / Imail_user_data_t udata; /* user data structure / Imail_msg_t msg; /* message to be delivered / int rval; / return value / char wpos; /* write position in message body */

/* Initialize variables an check for user authentication. */ if (NULL == (udata = f->private_data)) return -EPERM; msg = NULL; rval = 0;

/* Check that the file is writable. */ if (0 == (f->f_mode & FMODE_WRITE)) return -EBADF;

/* Read header structure into kernel address space. */ if (copy_from_user (&header, arg, sizeof (header))) return -EFAULT;

  • Check for recipient. Recipient MAY be deleted between this check
  • and message creation, but could also be deleted at any point between
  • this call and the call that delivers the message. This check works
  • for the more common case of writing to someone who has never existed. */ down_read (&user_list_rwsem); if (NULL == Imail_find_user (header.recipient)) rval = -ENOENT; up_read (&user_list_rwsem);

Problem 3, continued:

Describe the necessary tests here (at the level of detail shown).

Try to write a message to a non-existent Imail recipient; should return ENOENT.

Problem 4 (20 points): Synchronization

You have nearly completed the implementation of a device driver with a friend when you realize that the

device’s interrupt handler needs to access data protected by a Linux semaphore. Your friend suggests

wrapping all critical sections that use the semaphore with macros that save and restore the interrupt flag,

thus blocking interrupts during each critical section. The interrupt handler, your friend explains, then

needs no synchronization, since it cannot execute while the driver is in any critical section.

Part A (10 points): Explain the flaw in your friend’s reasoning and briefly describe a situation in which

the strategy fails.

Part B (5 points): Suggest an alternative strategy that allows you to continue using a semaphore to

protect the data and to access the data directly in the interrupt handler. In particular, be sure that your

solution solves the problem that you mentioned in Part A.

*** Part C (5 points): Describe the mechanism or mechanisms that Linux uses to enforce correctness

with the solution to Part B. Keep in mind that the mechanism(s) may be PIC-dependent.

Problem 5 continued:

Part B (8 points): State where the argument values should be placed (in which registers, memory

locations, etc.) in order to make a system call that executes the following function call within the kernel:

transmit (5, 8, 103);

(scratch paper)