Progress - Operating System - Exam, Exams of Operating Systems

These are the Exam of Operating System which includes Caller-Save, Trap Frame, Interrupt Handling, Latest, Processor-Architecture News, Building, Management, Analysis, Management etc.Key important points are: Progress, User Mode, Progress, Explanation, One-Paragraph, Clear, Grader, Understand, Applies, Trouble

Typology: Exams

2012/2013

Uploaded on 03/28/2013

rohit-sharma
rohit-sharma 🇮🇳

4.3

(11)

200 documents

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Science 15-410: Operating Systems
Mid-Term Exam (B), Spring 2008
1. Please read the entire exam before starting to write. This should help you
avoid getting bogged down on one problem.
2. Be sure to put your name and Andrew ID below and also put your Andrew ID at the top of
each following page.
3. This is a closed-book in-class exam. You may not use any reference materials during the
exam.
4. If you have a clarification question, please write it down on the card we have provided. Please
don’t ask us questions of the form “If I answered like this, would it be ok?” or “Are you
looking for ...?”
5. The weight of each question is indicated on the exam. Weights of question parts are estimates
which may be revised during the grading process and are for your guidance only.
6. Please be concise in your answers. You will receive partial credit for partially correct answers,
but truly extraneous remarks may count against your grade.
7. Write legibly even if you must slow down to do so! If you spend some time to
think clearly about a problem, you will probably have time to write your answer legibly.
Andrew
Username
Full
Name
Question Max Points Grader
1. 10
2. 20
3. 20
4. 15
5. 10
75
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download Progress - Operating System - Exam and more Exams Operating Systems in PDF only on Docsity!

Computer Science 15-410: Operating Systems

Mid-Term Exam (B), Spring 2008

1. Please read the entire exam before starting to write. This should help you

avoid getting bogged down on one problem.

  1. Be sure to put your name and Andrew ID below and also put your Andrew ID at the top of each following page.
  2. This is a closed-book in-class exam. You may not use any reference materials during the exam.
  3. If you have a clarification question, please write it down on the card we have provided. Please don’t ask us questions of the form “If I answered like this, would it be ok?” or “Are you looking for ...?”
  4. The weight of each question is indicated on the exam. Weights of question parts are estimates which may be revised during the grading process and are for your guidance only.
  5. Please be concise in your answers. You will receive partial credit for partially correct answers, but truly extraneous remarks may count against your grade.

7. Write legibly even if you must slow down to do so! If you spend some time to

think clearly about a problem, you will probably have time to write your answer legibly.

Andrew

Username

Full

Name

Question Max Points Grader

I have not received advance information on the content of this 15-410 mid-term exam by dis- cussing it with anybody who took part in the main exam session or via any other avenue.

Signature: Date

Please note that there are system-call and thread-

library “cheat sheets” at the end of the exam.

If we cannot read your writing, we will be un-

able to assign a high score to your work.

  1. 20 points Trouble at the Warehouse

After completing 15-410, you and your partner have been hired by a small Pittsburgh fruit-juice distributor to automate their warehouse. Here is how the warehouse operates.

  1. Big long-haul container trucks arrive from your suppliers. Each container truck contains either 1,000 cases of Odwalla juice or 1,000 cases of Jamba Juice. Generally each container truck is unloaded into the warehouse as soon as it arrives, though there are of course exceptions.
  2. Your company operates a small fleet of delivery trucks. Each delivery truck arrives at the warehouse seeking some number of cases of Odwalla and some number of cases of Jamba (the total number of cases a delivery truck can hold is 50). Once it loads what it needs, it will leave the warehouse and deliver them. Like container trucks, delivery trucks usually access the warehouse right away, but sometimes must wait.
  3. Container trucks park at one loading dock, and delivery trucks park at a different one, because their heights are different.
  4. Juice must be moved into and out of the warehouse by the warehouse’s one forklift (after you complete the exam you may wish to view the YouTube video on the AirTrax “Sidewinder”).
  5. To avoid a “denial-of-service attack” by one or the other juice manufacturer, the warehouse manager has imposed a constraint on container deliveries: if unloading a container would result in more than 80% of the warehouse being occupied by one manufacturer’s product, the container must wait.
  6. Because the warehouse is located in an industrial district with low land values, you may assume the neighborhood provides enough parking for your fleet of delivery trucks and as many container trucks as necessary.

Your partner was hired before you, and deployed the code depicted below. You may assume that all objects are properly initialized before use as part of system start-up.

/* Container loading dock */ mutex_t cd_m; int cd_avail; cond_t cd_released;

/* Delivery loading dock */ mutex_t dd_m; int dd_avail; cond_t dd_released;

/* Forklift --

  • locking simpler because both #contenders and hold
  • time are well bounded */ mutex_t fl_m;

/* Inventory management */ #define JTYPES 2 // 0=Odwalla, 1=Jamba #define CONTAINER 1000 // cases per truck #define CAPACITY 9000 // total cases per warehouse int avail[JTYPES];

01 void 02 container_arrival(int type) 03 { 04 int ready; 05 06 mutex_lock(&cd_m); 07 ready = 0; 08 while (!ready) { 09 while (!cd_avail) { 10 cond_wait(&cd_released, &cd_m); 11 } 12 cd_avail = 0; // claim 13 14 // Must not overflow warehouse 15 int total = avail[0] + avail[1]; 16 if ((total + CONTAINER > CAPACITY) || 17 (avail[type] + CONTAINER > ((80*CAPACITY)/100))) { 18 // No room, let somebody else try. 19 cd_avail = 1; 20 cond_broadcast(&cd_released); 21 // Retry when space freed up by delivery team 22 cond_wait(&dd_released, &cd_m); 23 } else { 24 ready = 1; 25 } 26 } 27 mutex_unlock(&cd_m); 28 29 // Use forklift to unload 30 mutex_lock(&fl_m); 31 operate_forklift(); 32 avail[type] += CONTAINER; 33 mutex_unlock(&fl_m); 34 35 // Drive away... announce container dock is free 36 mutex_lock(&cd_m); 37 cd_avail = 1; 38 cond_broadcast(&cd_released); 39 mutex_unlock(&cd_m); 40 }

(a) 10 points Something is very wrong with the way this code synchronizes the operation of the warehouse. Clearly explain what is wrong. You should probably provide an exe- cution trace, in the format presented in class, showing the problem in action. Obvious abbreviations are ok. For example: container(0) deliver({10,15}) unlock(cd m); unlock(dd m); If you cannot find a synchronization correctness problem, you may obtain partial credit by describing one “interesting” synchronization correctness problem the code does not have and briefly arguing why your claim is true. Avoid answers of the form “Such-and-such looks wrong, but I’m not sure why,” as these demonstrate understanding of the material poorly at best.

(b) 10 points Provide corrected code for one of the truck-arrival functions. If possible, try to maintain or reduce, rather than increase, the complexity of the system.

You may use this page as extra space for your warehouse solution if you wish.

  1. 20 points Dual-priority locking.

Different application architectures require different locking approaches. For example, later in the semester we will discuss how real-time scheduling increases the complexity of locking. This question is about a dramatically simpler situation. The application in question has threads of two differ- ent priorities, and some objects must be locked according to a priority-aware protocol. The key requirement is this: when one of these objects is unlocked, it must be acquired by a high-priority thread if any are waiting; otherwise it must be acquired by a low-priority thread if any are waiting.

Each time a thread acquires or releases one of these objects it will indicate whether it is a high- priority thread or a low-priority thread. Threads will not lie and will not change priorities.

You will provide us with both a structure definition for your dual-priority lock and the code for three functions.

  • void dlock init(dlock p dp)
  • void dlock acquire(dlock p dp, int isHigh)
  • void dlock release(dlock p dp, int isHigh)

You need not provide us with code for dlock destroy(). You are encouraged to use the Project 2 thread-library primitives. If necessary you may use other synchronization primitives, but you should strive to avoid this, as it may reduce your grade. You must comply with the published interfaces of synchronization primitives, i.e., you cannot inspect or modify the internals of any thread-library data objects. You may not use assembly code, inline or otherwise. For the purposes of the exam you should assume an error-free environment (memory allocation will always succeed; thread-library primitives will not detect internal inconsistencies or otherwise “fail,” etc.).

Note that you are not required to make the impossible guarantee that no high-priority thread ever waits for a low-priority thread. Furthermore, do not worry if your solution is very slightly imperfect in a way which is not avoidable in certain situations. In other words, the key requirement may be rephrased as follows: when an object is released, if any high-priority threads are waiting, at most one low-priority thread may obtain the object before a high-priority thread does, but the number of low-priority acquisitions in this situation should almost always be zero instead of one.

The remainder of this page is intentionally blank.

(b) 15 points Now please write dlock acquire() and dlock release().

You may use this page as extra space for your dual-priority lock solution if you wish.

  1. 15 points “Dead rock”

This semester, 410 students have formed four rock bands. Each band has a (small) set of songs they have practiced; each song requires an eclectic set of instruments.

Naturally the students are familiar with Professor Dannenberg’s prominence in the field of computer music and figure that instead of buying instruments they can borrow them from him. Roger’s collection contains these instruments. Accordion Bagpipe Cowbell Drum 4 3 2 5

The bands, their songs, and the instruments needed to play each song are listed in the table below. Note that each instrument, each band name, and each song title can be represented unambiguously by a 1-letter or 1-digit abbreviation.

Accordion Bagpipe Cowbell Drum

Band 1: One Thread Yielding Entry of the Threads 1 0 1 1 Free Memory 0 0 1 3

Band 2: Two Cores Groove Gettid 2 0 0 2 Hit The Break Jack 1 1 0 1

Band 3: Three Spare Bits Justify My Yield 0 1 1 1 Kill Dash Nine 3 0 2 2 Lock Free Your Heart 1 3 0 2

Band 4: Forth Mutex Romance 1 1 0 1 Never Going to Halt 2 2 0 4

There was a “battle of the bands” (popularity competition) last weekend, with these four bands and no others.

Because Roger was delayed by bad weather, the 410 students broke into his lab and each band borrowed the instruments necessary to play its first song (E, G, J, and M, respectively). Roger knows that each band is stubborn and will demand to go on stage and be allowed to play all of their songs in some order before being willing to yield the stage or return any instruments to Roger’s collection.

Roger is worried that the naive resource allocations made by the students plus their stubborn policy may have placed the system at risk of deadlock.

(a) 5 points Is there a safe sequence? If so, list a sequence of bands in order. If not, explain why there is not.

You may use this page as extra space for your deadlock solution if you wish.

(c) 5 points Now consider this variant on the protocol of Part B: after every song, each group takes a break (thus releasing all instruments) and then acquires instruments for their next song as described in the Part B protocol. Given all four bands, can this algorithm deadlock? Justify your answer.