-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.txt
More file actions
71 lines (54 loc) · 2.75 KB
/
report.txt
File metadata and controls
71 lines (54 loc) · 2.75 KB
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
Objectives:
This assignment is intended to give experience in developing multithreaded
programs that require thread synchronization and deadlock prevention. My
implementation uses mutexes. So they were the main focus for this.
How to use:
Makefile commands (assignment spec):
- Executing ‘make’ produces the a4tasks executable file.
- Executing ‘make clean’ removes any unneeded files produced in compilation and the `submit.tar` archive
- Executing ‘make tar’ produces the ‘submit.tar’ archive.
Running the program:
After compiling the a4tasks binary it can be invoked using the command line:
./a4tasks inputFile monitorTime NITER
Where the arguments are defined as:
inputFile: file describing the tasks to be executed.
monitorTime: integer (in milliseconds) that specifies how often a monitor thread runs.
NITER: integer noting the amount of iterations each task executes before the simulator finishes.
Design Overview:
In general, c++ code is used with functional programing. Code is also
separated into separate files to decrease recompile time and create logical
code separation.
1. main
- entry point to the program
2. task.h
- contains a struct for a task
3. taskManager
- runs the simulation
- contains the program logic
4. util
- handles mutex initialization, lock, and unlock
- handles pthread create and join
5. parsers
- parses CLI argurments and files into vars
- parses vars into strings
Three variables are global for the program: a resource map containing resource names to amount;
taskList, an array containing all the tasks from the file; and threads, an array containg all the
pthread_ts.
Three mutexes were used for the program. One controlls access to the resource map, a second controlls
access to tasks' assigned variable and a third controlls access to a task's assigned variable.
The entire input file is read before the timer starts for the run time and threads are created.
Project Status:
The program properly uses threads that take global resources and prints results as
specified in the example. So the program is complete and adheres to specifications
however due to the nature of the project an exact match was never made to the example output.
If letters are used as the monitor time or as nIter they will be taken as zero.
Testing and Results:
A continuous integration checker was used to ensure that the program always compiled and exited
with exit status EXIT_SUCCESS during development.
The example input were ran and loosely compared with example outputs. The program was run with
test files of my creation too.
Acknowledgments:
Linux man pages
https://linux.die.net/
mutex initialization, lock, and unlock & delay
http://webdocs.cs.ualberta.ca/~c379/F18/379only/raceC.c