From e0a12329878e3da666c22c27f4eb5ec296d12751 Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Thu, 2 Nov 2023 23:51:50 -0300 Subject: [PATCH] Finish a5 as much as it can be --- Assignment5/Process.md | 3 ++- Assignment5/README.md | 23 +++++++++++++++++++++++ Assignment5/hard_affinity.c | 16 ++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 Assignment5/README.md diff --git a/Assignment5/Process.md b/Assignment5/Process.md index ff6d964..421fcf5 100644 --- a/Assignment5/Process.md +++ b/Assignment5/Process.md @@ -4,4 +4,5 @@ 4. The print thread will wait on the sim sem for each CPU thread, and this should leave the sem at 0 again. 5. At the end of the print function, before the simulation is allowed to print again, the print thread will increase the time, and then post to the sim sem for each CPU thread, so the simulation can start again. 6. Repeat steps 3-5 until the simulation is done. -7. \ No newline at end of file + +This is the general process, at least at the time I wrote this down lmao \ No newline at end of file diff --git a/Assignment5/README.md b/Assignment5/README.md new file mode 100644 index 0000000..b556e54 --- /dev/null +++ b/Assignment5/README.md @@ -0,0 +1,23 @@ +# How to run + +To compile please run: +```shell +gcc -Ilib lib/process.c lib/queue.c hard_affinity.c +``` + +And to run please run: +```shell +./a.out < example.txt +``` + +# In case of error + +If that command to compile does not work, please place all C and C header files in the same directory and run: +```shell +gcc process.c queue.c hard_affinity.c +``` + +In case you need to move the files, for easy copying: +```shell +mv lib/process.c . & mv lib/queue.c . & mv lib/queue.h . & mv lib/process.h . +``` \ No newline at end of file diff --git a/Assignment5/hard_affinity.c b/Assignment5/hard_affinity.c index 53a1ff1..c699295 100644 --- a/Assignment5/hard_affinity.c +++ b/Assignment5/hard_affinity.c @@ -4,6 +4,22 @@ #include #include "lib/queue.h" +/* + * Marker, please read: + * + * There is a bug that I cannot track down/may be unsolvable with my current implementation. + * It's where *sometimes* the print function, after a thread finishes, it will print an extra time on one job (I think) + * + * This could probably be solved by running the "done threads" until all threads are complete, but I didn't have time to bugfix that + * implementation. I tried it, but it didn't work as is, so I reverted it. + * + * With that implementation it may have been beneficial to have an array of semaphores, one for each "CPU", that the print thread + * can for loop wait on each to complete. I think that would have worked, but I straight up didn't have time to implement it or try at all + * + * The comments may also not be the most helpful, didn't have time to go and clean them up + */ + + #define MAX_USERNAME_LENGTH 100 int *QUANTUM; int CPUS;