Programming in C, write a program in C
Write a multithreaded C program (using C and pthreads) that performs an encoding for a list
of characters using semaphores 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 < 97) char = char + 32;
Thread 2: char = char + 5;
Thread 3: 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.