This repository has been archived by the owner on May 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
199 lines (180 loc) · 8.09 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
PROGETTO II LabSO1 - AA 2019-2020 -- 201931, 202077, 201637, 201647
gruppo [email protected] - Variante Ubuntu
[email protected], Simone Alghisi, 202077
[email protected], Emanuele Beozzo, 201637
[email protected], Federico Izzo, 201931
[email protected], Samuele Bortolotti, 201647
-------------------------------------------------------------------
Makefile help:
* build : compiles the program and creates the executable files and object files
* buildMinimal : compiles the program and creates only the executable files
* clean : removes all file created during any kind of build operation
* cleanObj : removes all object files created during any kind of build operation
* help : print this file
* log : compiles the program with a preprocessor directive which redirects all components errors in a log file.
Then it creates the executable files and object files
* speed : compiles the program with a preprocessor directive which ignores all the sleeps.
Then it creates the executable files
-------------------------------------------------------------------
BELOW ARE LISTED SOME INFORMATION. MORE (WITH CHARTS AND IMAGES) ARE INSIDE RFC.pdf
Implementation choices:
Memory:
In most cases if malloc fails we closed the program because we think that if the user saturated the RAM,
he/she may prefer that some programs could free it to make the computer more usable.
Before reading from a file only the worker checks if there is enough free space in memory in order to read its work amount.
If not it allocates 50% of the free memory and reads multiples times from the file moving the cursor.
Empty folders:
We decided not to store information about empty folders.
If files are added later in a folder (that was previously empty) user needs to analyze it again
Changing file runtime:
If a file is changed while the workers are reading there are several possibilities:
* if the updated file is shorter/longer than the old one, we decided to handle the error but the statistic are not reliable,
so if the user want the correct one he/she needs to it analyze again.
* if the updated file has different permissions, workers are still able to read the file because
permissions are only verified when a file is opened and the statistic will be saved.
* if the file has been deleted, workers are still able to read the file because
as long as there is an open file descriptor the file’s data will not be deleted and the inode will not be freed.
The statistic will be saved anyway.
In any case the purpose of the program is to analyze files, so if the user changes them runtime
it completely lose its original meaning (errors must be handled anyway).
Manager/Worker amount changes:
If the manager/worker amount changes during the program execution we decided not to kill them
(except the case when the user wants less processes, and rare occasions - i.e. communication errors),
instead we reorganized their jobs.
If one or both of those amounts are equals (or below) zero, their task are stored until the number changes.
File distribution:
Files are scheduled to managers using a priority queue. In some cases this is the fairest way to assign them,
but, in some occasions (few and/or small files) only a small amount of managers are involved
(some/all files are analyzed before the whole distribution).
This happens because the priority is based on the amount of file, assigned to the manager, which still needs to be processed.
We thought about changing the priority with the total number of file assigned, but this isn't fair with big files
and analyzer shouldn't access files in any way to know their dimensions.
Thread:
We decided to use threads in all components in order to improve the user experience.
-------------------------------------------------------------------
Problems and difficulties:
* If / is given as path the program interrupt itself in some random moment.
This is caused by some strange file inside system's folders.
We tried to "make a rule" in order to handle them but there are too many cases
(we didn't have neither the time nor the means).
* If reporter is closed and open again several times very quickly
there is the possibility that the analyzer will die without any error message
* The executable files needs to be called inside the bin directory, otherwise the program won't work
(except for the reporter and worker).
* There is the possibility that the user clear the FIFO manually. If so the analyzer/reporter communicate will be compromised (we tried to delete FIFOs after creation but other major problems were found)
* If where we create the FIFOs does already exist a file with the same name owned by root with no reading/writing permission for the current user the FIFO can not be accessed
-------------------------------------------------------------------
How to use the program:
All the main components of the project can be executed standalone.
The user can build the program with different building option and executing it while being in the bin folder.
Follow the instruction on the screen, use help or see RFC.pdf.
-------------------------------------------------------------------
Project logic:
* analyzer : analyzer forks managers and keeps anonymous pipes with them
in order to stay informed
* config : contains preprocessor directives like error codes and flags
* list : a linked list implementation
* manager : manager forks multiple workers and keeps anonymous pipes with
them in order to get the stats gathered from files
* priorityQueue : a priority queue (heap based) implementation
* reporter : reporter keeps two pipes:
* analyzer -> reporter: in order to gathers data and computes
a report
* reporter -> analyzer: in order to sends user's requests
* table : holds counting information
* tree : a n-ary tree with list of children implementation
* tui : terminal user interface
* work : a worker's work
* worker : worker reads and computes the statistic operations on a portion
of a file assigned to it
* wrapping : utility functions
* main : calls reporter and analyzer after a fork
Directories logic:
.
|-- GIFME.gif
|-- Makefile
|-- README
|-- README.md
|-- RFC.pdf
|-- WATCHME.mvk
|-- bin
| |-- analyzer
| |-- analyzer.o
| |-- counter
| |-- list.o
| |-- main.o
| |-- manager
| |-- manager.o
| |-- priorityQueue.o
| |-- reporter
| |-- reporter.o
| |-- table.o
| |-- tree.o
| |-- tui.o
| |-- work.o
| |-- worker
| |-- worker.o
| `-- wrapping.o
|-- img
| `-- structure.png
|-- src
| |-- analyzer
| | |-- README.md
| | |-- analyzer.c
| | |-- analyzer.h
| | |-- manageFileThread.png
| | |-- readDirectivesThread.png
| | |-- readFifoThread.png
| | |-- sendFileThread.png
| | |-- treeInsertion.png
| | `-- writeFifoThread.png
| |-- config
| | `-- config.h
| |-- list
| | |-- list.c
| | `-- list.h
| |-- main.c
| |-- manager
| | |-- README.md
| | |-- directivesThread.png
| | |-- manager.c
| | |-- manager.h
| | `-- workThread.png
| |-- priorityQueue
| | |-- priorityQueue.c
| | `-- priorityQueue.h
| |-- reporter
| | |-- README.md
| | |-- readFifoLoop.png
| | |-- reporter.c
| | |-- reporter.h
| | |-- userInputLoop.png
| | `-- writeFifoLoop.png
| |-- table
| | |-- table.c
| | `-- table.h
| |-- tree
| | |-- tree.c
| | `-- tree.h
| |-- tui
| | |-- README.md
| | |-- UI.png
| | |-- screenshot.png
| | |-- tui.c
| | `-- tui.h
| |-- work
| | |-- work.c
| | `-- work.h
| |-- worker
| | |-- README.md
| | |-- Worker.png
| | |-- worker.c
| | `-- worker.h
| `-- wrapping
| |-- wrapping.c
| `-- wrapping.h
`-- team
|-- EmanueleBeozzo.png
|-- FedericoIzzo.png
|-- SamueleBortolotti.png
`-- SimoneAlghisi.png