Programming Homework Help

CSCI 3120 Dalhousie University Add Functions to Original Code C Programming Task

 

Extend your program from Assignment 3 (or the provided solution) to make the main thread of your miner
spawn a reader thread that is responsible for reading all the input. The reader thread should then insert
the input into a queue (buffer). The main thread will be responsible for dequeuing the input and processing it, just like in Assignment 3. This is essentially the Unbounded Buffer Producer-Consumer problem
where the reader thread is the producer, and the main thread is the consumer. Your program must be
compiled to an executable called miner. The program will read in five events, which are the same as in
Assignment 3. Please see the Problem Statementsin Assignment 1, 2 and 3 for a description of the events.
The reader thread should consist of a loop that reads events from stdin and enqueues them onto an
unbounded queue. The queue can never fill up, so a linked-list implementation is recommended.
The main thread will use the same main loop as in Assignment 3, except that instead of reading from stdin
it should dequeue events from the queue fed by the reader thread and process the events. Please note
that if the queue is empty, the main thread should block until more events are added by the readerthread.