Skip to content

Commit 9ea068f

Browse files
committed
Added a complete README
1 parent cfab92a commit 9ea068f

File tree

2 files changed

+95
-2
lines changed

2 files changed

+95
-2
lines changed

.gitignore

+10-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,13 @@ logs/*
6666
vgcore.*
6767

6868
# fuse_hidden files
69-
.fuse_hidden*
69+
.fuse_hidden*
70+
71+
# latex files
72+
*.aux
73+
*_latexmk
74+
*.fls
75+
*.log
76+
*.out
77+
*.synctex.gz
78+
_minted*

README.md

+85-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,86 @@
11
# SOL-Project-2021
2-
Final project for the Operating Systems course
2+
## A file-storage server
3+
4+
This repo contains my version of the final project for the Lab module of the Operating Systems and Lab course at UniPi, Academic Year 2020-2021. The project is released under a MIT License.
5+
6+
It implements a simple file-storage server that receives files and concurrent requests from several clients. The server process stores the files in memory (RAM) and acts as a file cache: whenever the reserved space is full files are ejected and sent back to clients. The client-server communication is based on an API library that implements the protocol for several operations, such as opening/reading/writing files and many more.
7+
8+
### General structure
9+
10+
The main source files are in the `src/` subdirectory; include files are in `includes/`. The `obj/` and `libs/` subdirectory are used for object files and dynamic libraries generated at compile time. The `bin/` subdirectory will contain the executables after a successfull compilation.
11+
12+
`config/` contains a single file, `config/config.txt` which specifies the main parameters for the server process.
13+
14+
`logs/` is the default directory in which log files written by the server app are stored. They can be parsed and analysed through the `scripts/statistiche.sh` script (which will be described later).
15+
16+
`report/` contains a report on the main implementation details of this project (written in italian).
17+
18+
`scripts/` contains some Bash scripts used to implement tests.
19+
20+
`tests/` contains random files to test some aspect of the project (mainly the client options and the replacement algorithm).
21+
22+
Some directories contain a `.keep` file: this file is used only to ensure that Git loads the directory.
23+
24+
### Compilation
25+
26+
A `Makefile` was created to ease the compilation procedure. It supports several options:
27+
- `make` compiles the whole project, creating the directories for object files, binaries and libraries if they don't exist
28+
- `make clean` cleans all auxiliary files and executables
29+
- `make test1` and `make test2` launch respectively the first and the second test. In particular the second test provides two more options:
30+
- `make test2FIFO` to test the FIFO replacement algorithm
31+
- `make test2LRU` to test the Least Recently Used replacement algorithm
32+
In the current version, `make test2` is equivalent to `make test2LRU`.
33+
- `make cleanTest1`, `make cleanTest2` and `make cleanTests` to clean files generated by the various tests
34+
- `make stats` tries to analyse the last log file present in `logs/` using the `scripts/statistiche.sh` script.
35+
36+
### Server config file
37+
38+
The server config file is (by default) located in `config/config.txt` but can optionally be specified by passing the config path as an additional argument to the server executable. The `config.txt` file has the following format:
39+
```
40+
no_worker = <number of worker threads>
41+
max_space = <max space in MBytes>
42+
max_files = <max number of files>
43+
cache_pol = <cache replacement policy, may be FIFO or LRU>
44+
sock_path = <path to socket file>
45+
path_dlog = <path to the directory containing log files>
46+
```
47+
There might be any number of spaces before or after the equal sign, or any number of empty lines between two different `key=value` lines, but all keywords must be present once and only once.
48+
49+
### Client options
50+
51+
A possible client is implemented and (after a successfull compilation) may be executed by giving the command `./bin/client`. All options and requests are given to the client through the command line. The possible optional argument can be seen with the option `-h`.
52+
53+
### API
54+
55+
The communication client-server is implemented through a dynamically linked library `libapi.so`. The API library may be freely used with a different client, but since it depends on a utility library `libutil.so` the two must be linked to the client object files.
56+
57+
### Scripts
58+
59+
The `scripts` directory contains some useful scripts:
60+
- `scripts/create_dirs.sh` creates several subdirectories (such as `obj/`, `bin/`, `libs/`, `logs/` and others) if they don't already exist (it is automatically called by `make`);
61+
- `scripts/test1.sh` and `scripts/test2.sh` are two tests (they may also be called through the Makefile, as described before). In particular the latter might be called with an optional argument representing the chosen replacement algorithm, which must be either `FIFO` or `LRU`. If no optional argument is given, `LRU` is assumed;
62+
- `scripts/statistiche.sh` computes some statistics on a log file generated by the server: if an optional argument is given it's interpreted as the path to a log file, otherwise the scripts takes the last log file present in the `logs/` directory.
63+
64+
### Optional features
65+
66+
The following table describes what *optional* features (*optional* for the summer exam term) were implemented.
67+
68+
| Feature | Implemented? |
69+
|----------------------------------|--------------|
70+
| LRU alg. ||
71+
| LFU alg. ||
72+
| Log files ||
73+
| File stats.sh ||
74+
| Compression ||
75+
| test3 ||
76+
| Send files to client (option -D) ||
77+
| Lock (-l) ||
78+
| Unlock (-u) ||
79+
80+
### Possible improvements and errors
81+
82+
- Source files don't *have* to be so split up. It isn't an error and I did it for my own sanity, but it isn't necessary.
83+
- To improve the logging performance, the logger function might maintain an internal buffer - that is, a list of things to print - and print the whole buffer once it reaches a certain capacity.
84+
- The logger should print something in case of fatal errors - for example a failed `safe_malloc`, that automatically aborts the process with an `exit(EXIT_FAILURE)`.
85+
- Utility functions (such as those in the `libutil.so` library, like `safe_malloc` or `safe_pthread_*`) **mustn't** abort the process without giving any choice to the programmer, even if the error is always fatal.
86+
- One way to solve this problem is to add an additional `bool` parameter to those functions: if the parameter is `true` on error the process is aborted, otherwise an error code is returned. This way the programmer may use the function *safely* and with full control over the function's behaviour.

0 commit comments

Comments
 (0)