This repository comprises the second project of the Operating Systems course unit project. The goal was to create a solution for a virtual access to a bathroom via FIFOs and threads.
It is intended to obtain a client-server application capable of handling conflict situations in access to shared memory regions.
The shared memory region is a bathroom with several unisex seats, controlled by a Q process, which receives requests from users. Access requests are sent through a multi-threaded process U (client), indicating the time that the users wishes be in the bathroom.
The artifacts for the version 2.0 can ve accessed here.
The source code for the version 1.0 can be accessed here, as well as the artifacts here.
The source files are located inside the src directory. The src directory has three subdirectories. The server directory is related to the server program, the client directory is related to the client program and the util directory contains useful files for both programs.
The documentation is generated automatically with doxygen and can be accessed here.
Run make in the root directory of the repository and the binary client and server files are placed inside a bin directory in the repository root. A symbolic link to each executable file is created in the root directory.
To run the client program use:
./U2 -t <number of seconds> <FIFO name>
- number of seconds, the number of seconds that the program must send requests;
- FIFO name, the name of the server's public FIFO.
To run the server program use:
./Q2 [-t <number of seconds>] [-n <number of threads>] [-l <number of places>] <FIFO name>
- number of seconds, the number of seconds that the program must receive requests;
- number of threads, the number of threads that are simultaneous handling requests;
- number of places, the number of available places in the bathroom;
- FIFO name, the name of the public FIFO.
Note: The argument specification does not follow any order.
The FIFOs are stored in the /tmp/ directory of the OS.
Exit Code | Name | Description |
---|---|---|
1 | Arguments Error | Defines an error with the arguments. |
2 | Connection Error | Defines an error connecting the client and the server. |
3 | FIFO Creation Error | Defines an error while creating or opening a FIFO. |
4 | Alarm Init Error | Defines an error when creating an alarm. |
5 | Thread Init Error | Defines an error when initializing a thread. |
Each feature is classified as bad, ok or great.
*SIGPIPE Handling - whenever a pipe is force closed (e.g. SIGINT, etc) any process that had the pipe opened receives a SIGPIPE. This was handled in order to continue the program after a SIGPIPE in any of the program's thread.
To run the tests run the shell script test_runner.sh in the test directory. The test verifies if the number of 2LATE logs are equal to the number of CLOSD logs. Log and err files are created in the test directory.
./test/test_runner.sh <server seconds> <client seconds> <bathroom places> <thread number> <FIFO name>
The output is OK if the test is successful, FAILED otherwise.
This repository contains the C code solution for the problem. Note that it might contain errors and should not be used as a solution.