UCF
School of computer Science
COT 4020: Programming Languages
Spring 2007
Homework 2 (BACI)
Due Wednesday 2007-03-28 by 11:59pm
Instructions
Implement the classic readers/writers problem in BACI (C-- style) using semaphores. You will need to implement three different behavior cases.
- Readers have precedence.
- Writers have precedence.
- Fair access policy (
first-come, first-serve). Sorry, confusing wording, I meant "Don't give preference to one type of access over the other".
In addition to this you should provide a sequence of Read/Write operations that can be used for testing that would provide differing return values based on the precedence policy. I.E. a sequence like R
1, R
2, R
3, W
1 would not fulfill this requirement because it would execute the same regardless of whether we are using policy 1 or policy 2. Include this sequence in the comments at the top of the file you submit. You can write Rn/Wn for reader/writer.
// As an example include your response like this at the top of your submission:// Testing sequence: R1, R2, R3,...
The reader and writer code should accept a number to identify the resource (n), then from within the function after executing the action the function should write "Rn " to standard out.
COBEGIN {
reader(1), writer(1), reader(2);
}
might write
R1 R2 W1
to the screen. In main, please print the output of each case run on a separate line so that I can tell which policy was used for the run set.
Example output:
Reader preference:R1,...Writer preference:R1,...Fair access:R1,...Rubric
Out of 100 points:
30 points each: implementing cases 1, 2, and 3.
10 points: testing sequence
Submission guidelines
In case of confusion I am available for clarifications. I will update the website in case of mass confusion and hysteria.
Include everything in one file named
hw2-`first initial + lastname`.cm ... e.g., I would submit a file called
hw2-cmillward.cmSubmit as an attachment via email to cmillward@cs.ucf.edu
Late submissions will not be accepted.
Plagiary and cheating will at the very least receive zeros.
Code that fails to compile will have heavy penalties.