The goal of this assignment is to gain an understanding of semaphores through the use of pthreads by designing and implementing a multi-threaded application. A secondary goal is to understand how semaphores are used in operating systems and applications. You are to write both a producer and a consumer C programs that uses pthreads to process and synchronize concurrent file activities.
Your solution must include the following:
1. The Consumer
Submits processing requests to the producer by supplying a file name, its location and a character. It also outputs the contents of the file provided by the producer to the standard output.
2. The Producer
Accepts multiple consumer requests and processes each request by creating the following four threads.
1 The reader thread will read an input file, one line at a time. It will pass each line of input to the character thread through a queue of messages.
2 The character thread component will scan the line and replace each blank character by the character supplied by the client. It will then pass the line to the toUpper thread through another queue of messages.
3 The toUpper thread component will scan the line and convert all lower case letters to upper case. It will then pass the converted line to the writer thread through another queue of messages.
4 The writer thread will write the line to an output file.
The producer will also return both the file name as well as its location to the consumer when the end of input file is reached.
1. You should develop a module that implements a queue of character string buffers.
2. This structure will be an array of pointers to strings with integers to indicate the head and tail of the list.
3. The maximum size of the buffer array will be 10.
4. Buffers will be created by the reader thread and destroyed by the writer thread.
5. Threads should terminate when end of input file is reached.