This program is to show the use of multithreading and to implement message passing through shared memory. The code in each thread that accesses the shared memory is a critical section, and you need to avoid race condition using the pthread library functions ??" pthread_mutex_lock and pthread_mutex_unlock ??" Write a program with three threads ??" reader, modifier, and printer. The reader thread reads an input file, one character at a time, and passes on the character to the modifier through a common buffer that can hold only one character. The reader should not send another character until the previous character has been taken by the modifier. The modifier thread receives the character from the common buffer with the reader. If the character is a, it sends the character % to the printer thread. If the character received is b it sends two stars (*) to the printer ??" one at a time. If the character received is c, then it sends three #’s to the printer ??" one at a time. All other characters are sent as they are received. Again the common buffer between the modifier thread and the printer thread can hold only one character, and the same restrictions as above also apply in this case. Finally, the printer thread prints the character received from the modifier thread ??" one character at a time. Use file1 of the previous project as input to this program also.
Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. "WITH COMMENTS" Complete copyrights to all work purchased.
## Deadline information
Dead line is 20th Feb. 1.00 pm US central time. CODE with COMMENTS.