diff --git a/Documents/readme b/Documents/readme new file mode 100644 index 0000000000000000000000000000000000000000..a3667929184cc3e2c3c07fb3023e57ac2e254fc4 --- /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 1fcf3ebc5567e36ba5efa98f8fd19056203fc53f..76f43282eb30f5943724400df5c6512740b11e4e 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. */