Student: Stanley

You are going to use the semaphores for process synchronization

Question I You are going to use the semaphores for process synchronization. Therefore, you are asked to develop a consumer and producer multithreaded program. Let us assume, that we have a thread (producer, we will call it producer_thread) reading data (positive integer numbers) from the keyboard, entered by a user to be stored in an array (dynamic array). (Assume that the array can hold all numbers entered without overflow.) Another thread (consumer, we will call it consumer_thread) should read data from the array and write them into a file. This thread should run concurrently with the producer (producer_thread). Your program should make sure that the consumer_thread can read from the array only after the producer_thread has stored new data. Both threads will stop when the user enters a negative number (well synchronized). Another thread (testing_thread) should start reading the array data as well as the file data and display them on the screen in order to verify if the consumer and producer have worked in a correctly synchronized fashion. This thread should not be synchronized with other threads, it is intended for testing that consumer thread is synchronized with produce thread. Provide your tutor with the source code as well as screen snapshots that show the work of the testing_thread. Question II Given the following mix of tasks, task lengths, and arrival times, compute the completion and response time (time from the arrival to the finish time) for each task, along with the average response time for the FIFO, RR, and SJF algorithms. Assume a time slice of 10 milliseconds and that all times are in milliseconds. Provide the Gantt chart as well. Scheduling Algorithms Job Length (secs) Arrival time FIFO RR SJF Completion time Response time Completion time Response time Completion time Response time 0 60 0 1 20 20 2 10 20 3 20 60 4 40 50 Average Response Time

Budget: $23.00

Due on: April 24, 2020 00:00

Posted: 12 months ago.

Answers (0)