In the programming question of Homework 2, there are two versions of the shared memory producer
–
consumer program (either leave one slot of the buffer empty to indicate an empty buffer or using all slots forstoring data. Write two pthread programs, each for one of the versions. In your code, consider “item” as a‘char’ type, and the main function creates two threads (producer and consumer). The producer read the textshown at this URL: “https://www.usenix.org/sites/default/files/usenix2…”, and write them, characterby character, to the buffer (you may first download the file and read from the local file). And the consumerreads from the buffer and print them to the screen, character by character. Your code’s logic should matchthat of the homework code.Observation: For each of the buffer sizes (2, 3, 5, 10, 15, 20, 25, and 30), measure number of trips for theproducer to deliver characters to the buffer in each version of the programs. A trip is defined as one ormultiple continuous writes to the buffer without being interrupted by a busy waiting (run into the “do nothing” code linedue the a full buffer). Insert code into your programs to collect the statistics and report
them in a table.