Threads and Scheduling
1# tsched
2
3This project is the second assignment for CCOM-4017. Check out the [instructions](instructions.md).
4
5I am using a sockets library I developed mysel. For more information on how the
6sockets library was developed, feel free to visit the repo:
7- https://tangled.org/@stau.space/enchufe
8
9This sockets library relies on having GNU's version of the POSIX utilities that
10should be available on a POSIX compliant system. Additionally, I am using GNU's
11implementation of semaphores, although they are not POSIX, they should be
12available on most systems.
13
14For threads, I am using a builtin library called `threads.h`. This library is
15documented on [cppreference.com](https://cppreference.com) as:
16- https://en.cppreference.com/w/c/header/threads.html
17
18From this library I used the functionality provided to create the threads and
19the mutex that they define.
20
21# Running
22
23If you would like to change the range of time that each program is sleeping,
24there is a macro called `SLEEP_TIME` defined in line 10 of `./src/edevice.c`.
25Changing this to some other number `n` will change the range of times to be `0`
26to `n - 1`.
27
28## Cluster
29
30```sh
31./build.sh cluster.py
32```
33
34This will simply run the cluster on the server's loopback `127.0.0.1` and on
35port `42069`. If youu want to supply your own server and port, use:
36
37```sh
38./build.sh cluster.py server_address server_port
39```
40
41where `server_address` is the IPv4 address of the cluster, and `server_port`
42is the port number of the cluster.
43
44## Embedded device
45
46This is the same as the cluster. The default server and port are the loopback
47and `42069` respectively, and supplying the parameters for `ADDRESS` and `PORT`
48will let make know on which server and port you want to run it.
49
50```sh
51./build.sh edevice.py server_address server_port
52```
53
54where `server_address` is the IPv4 address of the cluster, and `server_port`
55is the port number of the cluster.
56
57# Building
58
59If you just want to build the files, run:
60
61```sh
62make .build/edevice
63```
64
65To build the embedded device and run:
66
67```sh
68make .build/cluster
69```
70
71To build the cluster. From these two executables, you can then run the programs
72like,
73```sh
74./.build/cluster server_address server_port
75./.build/edevice server_address server_port
76```
77
78# Contributions
79
80I would like to thank Gabriel Romero, Pablo Torres, Sergio Rodriguez and
81Anasofia Colon while developing this project. Without them, this project would
82have been impossible.