Linux Kernel Problem Set: Synchronization, Virtual Memory, and Scheduling, Exams of Electrical and Electronics Engineering

Problem statements and solutions related to various topics in the linux kernel, including synchronization using read-copy update (rcu) scheme, virtual memory techniques and tradeoffs, and scheduling. The problems cover concepts such as tasklets, interrupt handling, quiescing, address translation, memory protection, and scheduling policies.

Typology: Exams

Pre 2010

Uploaded on 03/10/2009

koofers-user-4hl
koofers-user-4hl šŸ‡ŗšŸ‡ø

5

(1)

10 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE391 Exam 2, Spring 2006
Thursday 6 April
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Ɨ11"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!
ā€œ...though he did not know it, Rob McKenna was a Rain God. All he knew was that his working days
were miserable and he had a succession of lousy holidays. All the clouds knew was that they loved him
and wanted to be near him, to cherish him and to water him.ā€
—from So Long, and Thanks for All the Fish, by Douglas Adams
Problem 1 30 points
Problem 2 25 points
Problem 3 20 points
Problem 4 25 points
Total 100 points
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Linux Kernel Problem Set: Synchronization, Virtual Memory, and Scheduling and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

ECE391 Exam 2, Spring 2006

Thursday 6 April

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 Ɨ 11 " 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!

ā€œ...though he did not know it, Rob McKenna was a Rain God. All he knew was that his working days

were miserable and he had a succession of lousy holidays. All the clouds knew was that they loved him

and wanted to be near him, to cherish him and to water him.ā€

—from So Long, and Thanks for All the Fish , by Douglas Adams

Problem 1 30 points

Problem 2 25 points

Problem 3 20 points

Problem 4 25 points

Total 100 points

Problem 1 (30 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): As you may recall, the task state segment (TSS) of the x86 includes an I/O bitmap that allows

the task to use individual I/O ports directly from user-level ( i.e. , without a system call). Is it possible to leave this

bitmap out of the ISA and still avoid requiring system calls? If so, explain one way of doing without the bitmap and

describe an advantage of including it.

Part B (5 points): Explain how software disablement of specific interrupts (e.g., IRQ 10) works in Linux (as

opposed to masking the interrupt on the PIC). In particular, what actions are taken when a software-disabled interrupt

is raised by the hardware, and when (if ever) does the corresponding interrupt handler execute?

Problem 1, continued:

Part E (5 points): Explain the motivation for tasklets ( i.e. , software interrupts) in Linux. In particular, why not

just execute all interrupt-related activity in the (hardware) interrupt handler?

Part F (5 points): Describe one advantage and one disadvantage to interrupt chaining.

Problem 2 (25 points): Read-Copy Update Synchronization

This problem focuses on an advanced form of synchronization used in parts of the Linux kernel and asks you to

describe the benefits of the scheme.

Imagine that you have extended MP1 into a multi-player pong game with several paddle controllers based on artificial

intelligence (AI). In your game, the real-time clock’s interrupt handler adds and removes balls from the list of balls in

play, and each AI task repeatedly walks over the list of balls (inside a system call) in order to make informed decisions

about what to do next with its paddle.

Part A (6 points): You could choose to protect the ball list with a reader-writer spin lock. In this case, the

interrupt handler acquires a write lock to add or remove a ball, and the AI tasks acquire read locks to read the list of

balls. Explain why such a scheme is likely to fail on a multiprocessor but is probably acceptable on a uniprocessor.

Part of the implementation for the read-copy update (RCU) synchronization scheme appears on the next page, and is

used for the remaining parts of this question. The links in the ball structure are shown along with global variables (the

ball list, etc. ) and two pieces of code.

Under the RCU scheme, each AI task has a unique ID from 0 to NUM AI - 1 , and after each system call in which

the ball list is walked, the task calls the quiesce AI function on the next page. Pointers to balls are never saved in

data structures other than those on the next page, and are never returned to user level.

Under RCU, the interrupt handler can add and remove balls from the list without directly synchronizing its actions with

the AI tasks. To remove a ball, the interrupt handler first links around the ball in ball list without changing the

next list field of the ball that was removed. The interrupt handler then links the ball into the ā€œhotā€ list of discarded

balls, i.e. , the list pointed to by q hot. Note that the interrupt handler does not call kfree on the dynamically-

allocated ball structure. Eventually, discarded balls are cleaned up by some AI task inside of quiesce AI.

Part B (4 points): Explain why balls that have been successfully removed from ball list cannot safely be

freed by the interrupt handler using kfree.

Problem 2, continued:

Part C (6 points): Write the remove ball function, which is called by the interrupt handler to eliminate a ball

(as described earlier).

void remove ball (ball t* b) {

Part D (4 points): Adding balls to the ball list is easier and does not involve any deferred work. What

ordering (if any) must be obeyed when changing the link fields in the new ball and modifying global variables? In

particular, mention all necessary changes and explain any constraints on the order of changes that must be made to

add a ball.

**Part E***** (5 points): Use the structure of the quiesce AI function to prove that balls are never freed and

subsequently used by one or more of the AI tasks. Hint: draw a timeline.

Problem 3 (20 points): Virtual Memory Techniques and Tradeoffs

For each of the following three issues, explain briefly how they are handled for both segmentation and paging on x86.

Write no more than two sentences for each question.

Part A (4 points): Address translation requires additional memory accesses, which can be slow.

Part B (4 points): Some memory should not be accessible to unprivileged users.

Part C (4 points): The operating system may not want to use this virtual memory architecture.

Problem 4 (25 points): Scheduling

The diagram below illustrates scheduling decisions made by the Linux scheduler for one processor in a two-processor

system over a period of time (from left to right). Processes scheduled on the second processor are not shown. The

black sections represent interrupt handlers executed in response to the timer ticks. Assume that the timer interrupt

handlers shown are executed by both processors in the system at the same time. No other interrupts occur other than

those shown. No task schedules any kernel timers for the time period shown.

a b c

A total of four tasks are in the system:

Task 1, the dark task, has realtime priority.

Task 2, the medium task, has realtime priority equal to that of Task 1.

Task 3, not shown, has realtime priority equal to that of Task 1.

Task 4, the light task, has normal priority.

All four tasks are runnable at point a in the diagram. Questions A-E refer to the diagram.

Part A (3 points): What task(s) might be running on the other processor at point b?

Part B (4 points): List the types of scheduling policies for realtime jobs in Linux, and give a one-line explanation

of each policy.

Part C (3 points): If possible, state the realtime scheduling policy for each of the realtime tasks (Tasks 1, 2, and

3). If this is impossible to tell (for a particular task) from the information given, give a brief explanation why.

Part D (4 points): What happened in Task 2 at point c on the timeline?

Part E (6 points): Assume that Task 1 remains runnable throughout the interval shown. Describe a scenario that

would produce the schedule as shown after point c.

Part F (5 points): In general, is the concept of epochs necessary to schedule realtime jobs? Why or why not?

(scratch paper)