This document describes two challenges.
Challenge 1. The Produce-Consumer Problem
This section describes the first challenge needed to be completed as part of your final evaluation. The code with the solution has already been produced for you (the code is available in Canvas in the file named challenge1.c. Your job is to explain how the program solves the producer-consumer problem by including comments on the source code provided. You must also include comments, at the top of the code, that include your SID, general explanation of the purpose of the code and instructions on how to compile and run the program.
A very common problem in computing is the problem of the producer-consumer. This problem is a classic example on multi-process synchronisation. The description of the problem is as follows:
“The problem describes two processes, the producer and the consumer, who share a common, fixedsize buffer used as a queue. The producer's job is to generate data, put it into the buffer, and start again. At the same time, the consumer is consuming the data (i.e., removing it from the buffer), one piece at a time. The problem is to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer.
The solution for the producer is to either go to sleep or discard data if the buffer is full. The next time the consumer removes an item from the buffer, it notifies the producer, who starts to fill the buffer again. In the same way, the consumer can go to sleep if it finds the buffer empty. The next time the producer puts data into the buffer, it wakes up the sleeping consumer. The solution can be reached by means of interprocess communication. An inadequate solution could result in a deadlock where both processes are waiting to be awakened. The problem can also be generalized to have multiple producers and consumers.” (Wikipedia, 2018)
Challenge 2. Priority Scheduling
This section describes the second challenge needed to be completed as part of your final evaluation. The code with the solution has already been produced for you (the code is available in Canvas in the file named scheduling.c. Your job is to explain how the program performs priority scheduling by including comments on the source code provided. You must also include comments, at the top of the code, that include your SID, general explanation of the purpose of the code and instructions on how to compile and run the program.
Priority scheduling is a method of scheduling processes based on priority. In this method, the scheduler chooses the tasks to work as per the priority, which is different from other types of scheduling, for example, a simple round robin.
Priority scheduling involves priority assignment to every process, and processes with higher priorities are carried out first, whereas tasks with equal priorities are carried out on a first-come-first-served (FCFS) or round robin basis. An example of a general-priority-scheduling algorithm is the shortest-job-first (SJF) algorithm.
The solution provided in the code scheduling.c uses priority-based scheduling.