A C timer using a multithreading producer consumer architecture.
This repo is about the final assigment on the real-time embedded systems class .
The timer's implementation is in the file timer.c
For executing the program on a Linux Deskt Machine you have first to compile it,
by executing the command bellow inside the project folder :
gcc timer.c myFunctions.c -pthread -o program.out -lm -O3
after compilation finish you are able to execute the programm with the following command
./program.out s q
, where s is the common queue size you want to have and q the number of consumers,
for instance if you want to have a queue with capacity of 4 and 2 consumers threads you have to run the command:
./program.out 4 2
if queue size and number of consumer threads are not set as expected, both values are set by default to 4.
(Cross-)Compiling and Execution for a Raspberry Pi with this OS img
In order for be able to execute the programm to a embedded system (for me a raspberry pi 4 model B),
it has first to be compiled in such a way. This can happen with a cross compiler.
The cross compiler used for this project is given in this link, and bellow the proccess followed:
1.Choose the right compiler for our model and follow the proper quide here
2.Compile our source code with the command bellow :
arm-linux-gnueabihf-gcc timer.c myFunctions.c -pthread -o program.out -lm -O3
3. Transfer our executable to our embedded system, possible with scp
command.
Then it is possible to execute our programm inside our embedded system, with the command
bellow, in the directory where the executable file has been transfered:
./program.out s q
, where s is the common queue size you want to have and q the number of consumers,
for instance if you want to have a queue with capacity of 4 and 2 consumers threads you have to run the command:
./program.out 4 2
if queue size and number of consumer threads are not set as expected, both values are set by default to 4.