Question: You are to implement the program below in C. This project simulates a buffered video streaming service. The main program (process) sets up resource that

You are to implement the program below in C.

This project simulates a buffered video streaming service. The main program (process) sets up resource that are shared by all threads of the process . The shared resources include semaphores, a data buffer, and a file pointer.

The main program takes in an input parameter ,which is the name of the video file to be streamed (a text file) . The data buffer, which is an array of characters (six in total), is used to store data chunks (one data chunk is represented by one character). The data buffer can store up to six data characters . The main program spawns one producer and one consumer thread for each character buffer (total of 12 threads) . The producer reads in a character in the order of the file and adds the character to the buffer. A consumer thread reads character from the buffer in first - in - first - out (FIFO) order . The consumer thread prints to the standard output (stdout) right after it consumed the character from the buffer. When the file reaches its end, all threads terminate. After all threads terminated, the main program finishes .

In writing your program, you need to use some thread library functions such as pthread_create, pthread_join, sem_init, sem_wait, and sem_post . You should use the - lpthread or - pthread option when compiling and linking all program modules .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!