CS460 Midterm Exam #5
                    Due: 10-05-2023

1. Semaphores in 5.9: Impllement P()/V() operations on semaphores.

2. Pipes using sleep/wakeup in 5.13.2.2 and 5.13.2.3

3. Complete pipe specifications:

Reader and writer processes of a pipe are synchronized as follows:

When a reader reads from pipe, if the pipe has data, the reader reads as much
as it needs (up to the pipe size) and returns the number of bytes read. If the
pipe has no data but still has writers, the reader waits for data.(When a writer
writes data to a pipe, it wakes up the waiting readers, allowing them to
continue). If the pipe has no data and also no writer, the reader returns 0.
In that case, the reader should stop reading from the pipe.

When a writer writes to pipe, if the pipe has room, it writes as much as it
needs to or until the pipe is full, i.e. no more room. If the pipe has no room
but still has reader, the writer waits for room. (When a reader reads data from
the pipe to create more rooms, it wakes up the waiting writers, allowing them to
continue). However, if a pipe has no more readers, the writer must detect this
as a BROKEN PIPE error and aborts, e.g. return -1 or terminate.

Pipes in 5.13.2.2 do NOT meet the complete specification, e.g. it does NOT
handle the abnormal consitions.

		 
                           REQUIREMNTS

Implement pipe by using P/V on semaphores for process synchrpnization AND
handle abnormal conditions as specified in 3.