From 6fb31963bb10dfeb4f5844bd625c6895ce4e8a92 Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Sat, 10 Mar 2018 17:18:45 -0500 Subject: [PATCH] Add readme --- Documents/readme | 9 +++++++++ Main.c | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 Documents/readme diff --git a/Documents/readme b/Documents/readme new file mode 100644 index 0000000..a366792 --- /dev/null +++ b/Documents/readme @@ -0,0 +1,9 @@ + +Readme for A4 "Bounded Buffer" program +-------------------------------------- + +To run make program, run "make all". + + +To run program, run make and then run "a4" with appropriate args. +For args details and additional comments, see top of "Main.c" file. diff --git a/Main.c b/Main.c index 1fcf3eb..76f4328 100644 --- a/Main.c +++ b/Main.c @@ -11,15 +11,24 @@ * * Args: * First arg determines overall sleep time for the program. - * Main thread will directly use this arg as the sleep time, as long as it is greater than MIN_SLEEP. - * Subthreads' max sleep will be this arg modded by SLEEP_MAX. + * Main thread will directly use this arg as the sleep time, as long as it is greater than SLEEP_MIN. + * Subthreads' max sleep will be this arg modded by SLEEP_MAX. And no less than SLEEP_MIN. * Second arg is number of producer threads to create. * Third arg is number of consumer threads to create. * + * + * Size of buffer is defined in buffer.h by BUFFER_SIZE. + * Currently set to 5 to (nearly gauranteed) test: + * Both multiple insertions and removals. + * Buffer case of all indexes full. + * Buffer case of all indexes empty. + * + * * Program first creates consumer and producer threads, based on provided args. * Once all threads are initialized, main sleeps based on args provided. * When main wakes up, it terminates all threads and closes program. * + * * While main is sleeping, all threads enter loop of: * * Initially sleep for random period of time between SLEEP_MIN and SLEEP_MAX * (to ensure as much thread unpredictability as possible). @@ -30,6 +39,7 @@ * * Return out of thread-safe functions and read out either value that was added or value that was taken * (depending on if producer or consumer). If error occured, will be printed here. * + * * To make random numbers less random by using a constant seed on every run, comment out line #122 in main. */ -- GitLab