Docsity

Additional Synchronization Problem - Assignment 1 | CSE 430, Assignments of Operating Systems

Toggle sidebar
bg1
CSE 430 OS/161 Assignments 1c
Additional Synchronization Problem
Revised Monday November 10, 2008
In this assignment you will code a test program that uses the synchronization functionality
available in OS/161 and that exercises your understanding of concurrency. The entire
Assignment 1 has 3 parts:
1. Implementing and Testing Semaphores – ASST1a
2. Implementing and Testing Condition Variables and Locks – ASST1b
3. Additional Synchronization Problem ASST1c
This write-up is for ASST1c.
Hard copy portions of ASST1c are due on the day indicated on the course outline available on
the class web site. In particular the hard copy portions are due by class time and the patch file
must be submitted by midnight.
The OS/161 Information page available via the OS/161_info link in the left frame on the class
web site main page has information and links to all the necessary support information on running
this project and submitting hard copy and patch file deliverables.
Building the Kernel
You should use the kernel you untarred and configured in ASST1b.
You compile, build, install and run your kernel just as you did in ASST1b except you use
command 1c to run Stoplight or 1d to run Bounded Buffer.
Programming Section
You will code a synchronization program that uses the synchronization functionality available in
OS/161. You can use semaphores and/or the locks and condition variables you implemented in
ASST1b. There are two synchronization programs: Stoplight and Bounded Buffer. You are to do
one of these
Synchronization Test Problems
For ASST1c you will implement and test the Stop light or the Bounded Buffer synchronization
problem just as you did for catlock.c in ASST1b except that you can implement it using
semaphores and/or the locks and condition variables you added to the OS/161 source code.
These new programs are called stoplight.c and boundbuf.c. The deliverables that will be graded
for stoplight.c and boundbuf.c are the same as are stated for catlock.c in ASST1b. Test files
containing skeleton code for the stoplight.c and boundbuf.c programs can be found in the
kern/asst1/ directory of the OS/161 kernel source. After you have coded a solution for one
of them, you need to replace the skeleton file with your updated version and compile, rebuild and
install the OS/161 kernel as you did earlier when you started with the catlock.c skeleton file.
pf3
pf4

Partial preview of the text

Download Additional Synchronization Problem - Assignment 1 | CSE 430 and more Assignments Operating Systems in PDF only on Docsity!

CSE 430 OS/161 Assignments 1c Additional Synchronization Problem Revised Monday November 10, 2008 In this assignment you will code a test program that uses the synchronization functionality available in OS/161 and that exercises your understanding of concurrency. The entire Assignment 1 has 3 parts:

  1. Implementing and Testing Semaphores – ASST1a
  2. Implementing and Testing Condition Variables and Locks – ASST1b
  3. Additional Synchronization Problem ASST1c This write-up is for ASST1c. Hard copy portions of ASST1c are due on the day indicated on the course outline available on the class web site. In particular the hard copy portions are due by class time and the patch file must be submitted by midnight. The OS/161 Information page available via the OS/161_info link in the left frame on the class web site main page has information and links to all the necessary support information on running this project and submitting hard copy and patch file deliverables. Building the Kernel You should use the kernel you untarred and configured in ASST1b. You compile, build, install and run your kernel just as you did in ASST1b except you use command 1c to run Stoplight or 1d to run Bounded Buffer. Programming Section You will code a synchronization program that uses the synchronization functionality available in OS/161. You can use semaphores and/or the locks and condition variables you implemented in ASST1b. There are two synchronization programs: Stoplight and Bounded Buffer. You are to do one of these Synchronization Test Problems For ASST1c you will implement and test the Stop light or the Bounded Buffer synchronization problem just as you did for catlock.c in ASST1b except that you can implement it using semaphores and/or the locks and condition variables you added to the OS/161 source code. These new programs are called stoplight.c and boundbuf.c. The deliverables that will be graded for stoplight.c and boundbuf.c are the same as are stated for catlock.c in ASST1b. Test files containing skeleton code for the stoplight.c and boundbuf.c programs can be found in the kern/asst1/ directory of the OS/161 kernel source. After you have coded a solution for one of them, you need to replace the skeleton file with your updated version and compile, rebuild and install the OS/161 kernel as you did earlier when you started with the catlock.c skeleton file.

Stoplight Find a solution to synchronize the usage of the intersection to avoid gridlock. The intersection contains four quadrants as shown above, and cars travel on the right side of the road. A car traversing the intersection passes through one to three quadrants. Assume u-turns are prohibited at this intersection. For example, a car approaching from the North passes through the NW quadrant if turning right, the NW→SW quadrants if going straight, and the NW→SW→SE quadrants if turning left. Note that the order of traversal of the quadrants is significant. Before continuing think about the following two questions:

  1. Assume cars follow the convention that whoever arrives at the intersection first proceeds first. In what way is this method suboptimal?
  2. Assume cars do not follow the above convention. How could a deadlock occur in the intersection? Your solution must satisfy the following four requirements:
  3. Only one car is allowed in a quadrant or otherwise a collision occurs.
  4. No passing is allowed. In other words, if two cars approach from the same direction and head in the same direction, then the first car to reach the intersection will also reach its destination first.
  5. Do not allow traffic flow in any one direction to starve traffic flow in any other direction.
  6. Each car should print descriptive messages as it approaches, enters, and leaves each quadrant of the intersection indicating its car number, approach direction, destination direction and quadrant. *5. Multiple cars should be allowed within the intersection so long as they are in different quadrants, e.g., one or two cars going from south to north should be allowed in the intersection with one or two cars going from north to south and a car going south turning west should be allowed in the intersection at the same time as a car heading north turning east is in the intersection.
  • Extra extra credit is given for part 5 – see below. Skeleton code for the intersection model is in os161-1.10_asst1/kern/asst1/stoplight.c. You can replace or modify any part of this code you want or you may start from scratch. North

Project Deliverables and Grading One synchronization program called ASST1c is required. It can be either Stoplight or Bounded Buffer and is worth 5 points.

  1. (2 points) Hard copy of the stoplight.c or boundbuf.c source file with the parts added/changed indicated by comments. Comments can be brief. Block comments can help but are not required.
  2. (2 points) A very brief design document that outlines your implementation of this assignment. It should include the following:  Description of your implementation of Stoplight or Bounded Buffer. You should explain your approach, and why it works while preventing starvation and deadlock.  Additionally you should explain how you are testing for undesirable conditions in your code. See the Synchronization Test Problems Section above for examples. In particular for the Bounded Buffer problem you should describe  How underflow/overflow is prevented  Why count of items in the buffer is correct, i.e., how only one producer/consumer can put/take an item into/out of buffer at a time  Why program works for different size buffers  How you test for o No underflow/overflow o Count being correct And in particular for the Stoplight problem you should describe  How starvation/deadlock is prevented  How mutually exclusive access to quadrants is guaranteed  Why first car into intersection from a given direction going in same direction as another car leaves first  How conflicting requests to enter a quadrant by cars coming from different directions are resolved  How you test for/demonstrate that o No starvation/deadlock exists o Only one car in a quadrant at a time
  3. (2 points) Program output during execution. The simple way to demonstrate most of these things is to add assert statements to your code and include assert and kprintf statements in your test programs and then use any of the methods for capturing program output listed in the OS/ Projects Program Output Hard Copy Submission Information Page reachable from the OS/ Information page on the class website.
  4. (4 points) Electronic submission of an ASST1 patch file generated and submitted as per the description available on the OS/161 Projects Patch File Generation and Submission Information page reachable from the OS/161 Information page on the class website. If Stoplight is chosen there are 3 points total of additional extra credit for demonstration of correct handling of multiple cars in the intersection at the same time for (a) cars going in the same direction, (b) cars going in opposite directions and (c) cars making turns. As for ASST0, ASST1a and ASST1b you are invited to:
    1. Report any bugs or problems in the assignment, the web support or the write-up.
    2. Give your thoughts on the suitability of this assignment for cse430.