Menu

(Solved) : Write Producer Consumer C Programs Uses Pthreads Process Synchronize Concurrent File Activ Q37298010 . . .

You are to write both a producer and a consumer C programs thatuses pthreads to process and synchronize concurrent fileactivities.

The Details

Your solution must include the following:

  1. The Consumer
    Submits processing requests to the producer by supplying afile name, its location and a character. It also outputs thecontents of the file provided by the producer to the standardoutput.
  2. The Producer
    Accepts multiple consumer requests and processes eachrequest by creating the following four threads.
    1. The reader thread will read an input file, oneline at a time. It will pass each line of input to the characterthread through a queue of messages.
    2. The character thread component will scan theline and replace each blank character by the character supplied bythe client. It will then pass the line to the toUpper threadthrough another queue of messages.
    3. The toUpper thread component will scan theline and convert all lower case letters to upper case. It will thenpass the converted line to the writer thread through another queueof messages.
    4. The writer thread will write the line to anoutputfile.          

The producer will also return both the file name as well as itslocation to the consumer when the end of input file is reached.

Implementation Details

  1. You should develop a module that implements a queue ofcharacter string buffers.
  2. This structure will be an array of pointers to strings withintegers 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 bythe writer thread.
  5. Threads should terminate when end of input file isreached.

Expert Answer


Answer to You are to write both a producer and a consumer C programs that uses pthreads to process and synchronize concurrent file…

OR