



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CSE 430 OS/161 Programming Assignment 1a (ASST1a) Synchronization Using Semaphores Version 6 Saturday November 1, 2008 In this assignment you will be using the basic semaphore synchronization functionality that is in the OS/161 kernel. You will code a test program that uses this functionality and exercises your understanding of concurrency. The entire Assignment 1 has 3 parts:
We are now ready (finally) to build an actual object OS/161 kernel, called kernel-ASST1 that will run on the System/161 emulator. From the os161-1.10_asst1 directory perform the following steps. They will be explained after doing this.
below. After you have coded a solution to it, you need to replace the skeleton file with your updated version and reconfigure and rebuild the OS/161 kernel as on page 1 of this assignment. Cat & Mouse You are to use the P and V semaphores supplied with OS/161 to solve the catsem synchronization problem described below. You have cats and mice that are caged in different areas. In between these areas is a feeding area that has a certain number of feeding bowls. You need to regularly feed both the cats and the mice while preventing the mice from getting eaten. If a cat is eating at a bowl and sees a mouse, the mouse will get eaten. If a mouse is at a bowl eating, and a cat comes out, the mouse will get eaten. Cats and mice can never be at the feeding bowls at the same time. You are to write catsem with the provided specifications. Skeleton code for catsem is in kernel/asst1/catsem.c. You may start from this code or you may start from scratch. The requirements that will be graded for Cat & Mouse are: Neither group should be allowed to starve, they both must be fed regularly You should try to keep all bowls utilized. So, if you have 2 bowls, 2 cats or 2 mice should be eating at the same time as often as possible. You shouldn’t just act as though there is just a single bowl and only feed 1 cat or mouse at a time. You should write the code so that it will work if the number of cats, mice, or feeding bowls is changed. Your solution should demonstrate that it works for at least two bowls, 3 cats and 3 mice and every cat and mouse eating at least twice. In addition, all eating should eventually end. There should be at least 2 eating sessions during which both cats and mice eat (but not at the same time) and each cat and each mouse should eat exactly once during an eating session. Each animal thread should check if it is violating the condition that cats and mice can’t see each other in the feeding area. Additional Information OS/161 Thread Tests OS/161 has thread tests that are built into the kernel. If you explored OS/161 in the previous assignment you might have come across these under the tests (?t) menu. You may also have noticed that the sy1 test succeeds and tests sy2 and sy3 fail when you attempt to run them. This is because the kernel has not implemented the locks for sy2 or the condition-variables for sy. You should examine the code for sy1 in the kernel to see examples of how P and V semaphores can be used. The function that ultimately implements the sy1 terminal command is called semtest and can be found in kern/test/synchtest.c. Due to limitations in the kernel memory manager, you may get a memory error if you try to run too many sy1 tests. Simply restart the kernel and try it again.
Project Deliverables and Grading (12 points + 2 points extra credit)