Lab 12
Lab 12
BSCS-9ABC
Introduction
The purpose of this lab is to make the server built in lab 11 safe for multiple users.
Recap: in lab 11, you developed a server that provides remote access to the file system
developed in lab 9.
In this lab, we will protect the files from the readers-writers problem. The description of this
problem is available in section 7.1.2 of your textbook. You may use monitors, locks or
semaphore libraries provided by the APIs to implement the tasks.
Objectives
By the end of this lab you will have learned the practical uses of synchronization and
implemented it on the readers-writers problem.
Lab Task
Multiple threads can attempt to access files. You are required to implement mutual exclusion
for the access of files. There are two tasks and you may choose to complete any ONE task.
1. Implement a queue for readers. Multiple threads can attempt to read a file and some
can request a write.
○ You need to make sure that while a file is being read, no writer is allowed
(while maintaining the order of writes).
○ Any request to open a file in write mode means the file is considered to be in
active write mode until the user closes the file.
○ Similarly any request to open a file in read mode means the file is considered
to be in active read mode until the user closes the file.
○ Multiple users can read the file concurrently but writes must be mutually
exclusive.
2. Implement a limit on the number of usernames that can access a file.
2
○ Multiple users can access your system.
○ Any user may not access more than five files at one time (though, it is not
required that you implement any type of security).
○ If more than five requests are placed, then the requesting thread must wait.
○ Each file can only be accessed by three users (whether it be it for read or write
access).
Your system should implement all the Requirements listed in Lab 11.
Deliverables