This assignment has three parts. The first two parts will expose you to the usage of locks and semaphores in a program written by your instructor. The third part of the assignment will ask you to write a program that solves one of the classical IPC problems.
You will develop and run your programs in a UNIX environment, on one of University's SGI machines.
You will turn in:
In addition you will e-mail all relevant files to your instructor. In each case you must clearly indicate how to build the executable and how to use it. Your code must follow the coding style and documentation standards recommended in the Department.
a) What is the value the variable SharedCounter would have if the NUMBER_OF_PROCS processes would run strictly serialized (i.e. a new process would start only after the previous one has finished)?
b) Compile the program and run it a few times (ten times would probably be enough). Do you get the answer you expected? Explain.
c) Fix the problem. You will need to read more about the functions available: try for instance man m_lock. Run the new program (call it share_locks.c) to make sure it always prints the same result. The best way to do this is to have the function that updates SharedCounter run some number of times (MAX_TRIES) and make sure the value of SharedCounter is the expected one.
This part of the assignment is worth 20 points.
This part of the assignment is worth 30 points.
SSN mod 5 + 1 |
Use semaphores in your solution(s). The program should print some meaningful messages indicating what's going on.
This part of the assignment is worth 50 points.
Last update: June 8, 1997 | The cs450 home page. | Virgil Bistriceanu's home page. | The Computer Science and Applied Mathematics home page |