Question: Very important question. Please answer it very properly 9) You are to write a multithreaded program (using C and pthreads) that performs an encoding for

Very important question. Please answer it very properly
9) You are to write a multithreaded program (using C and pthreads) that performs an encoding for a list of characters using mutexes NOT pipes. Your program will read a series of characters from standard input (scanf()) and then will create three separate worker threads. Each thread will perform a simple change to the character in turn to produce the encoding. The first thread will convert the character into lower case. The second thread will shift the character 5 places higher. Lastly, the third thread will make sure the character did not overflow the lower case characters. So, more precisely: Thread 1: if (char 122) char = char 26; For example, suppose your program is passed the chars (a newline denotes the end of input). AaZT The program will report Ffey The parent thread will read each character and pass it along to the first thread to start the encoding. The first will pass the result to the second, and the second to the third. To help, you can assume that I have provided a queue implementation with the functions: queue_t* init_queue(); /* initializes an empty queue and returns a pointer to it */ int is_empty(queue_t* theQ); /* returns 1 if theQ is empty, 0 otherwise */ int is_full(queue_t* theQ); /* returns 1 if theQ is full, 0 otherwise */ int enqueue(queue_t* theQ, char c); /* adds char c to theQ returns 1 on success, 0 otherwise */ char dequeue(queue_t* theQ); /* returns the char dequeued from theQ - ' ' otherwise */
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
