Solved CSCI 460: Operating Systems—Assignment 2 (8 marks)

$30.00

Original Work ?

Download Details:

  • Name: producer-consumer-yves7d.zip
  • Type: zip
  • Size: 73.09 KB

Category: Tags: , , You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

This assignment is on process/thread synchronization. You will implement a variation
of the Producer/Consumer problem. Assume the following:
a. The buffer is a doubly linked list (for this assignment, let us assume that it contains
at most 30 nodes). Each node has a random integer value (which should be less than 50).
Initially the linked list contains 3 nodes.
b. Producer #1 will generate a node and add it at the end of the linked list, the value of
the new node is a random odd integer less than 50. Producer #2 will generate a node and
add it at the end of the linked list, the value of the new node is a random even integer
less than 50. When the buffer is full, both should generate a message and wait.
c. Consumer #1 will delete, from the head of the list, the first node whose value is odd
(if the first node has an even value, then wait). Consumer #2 will delete, from the head
of the list, the first node whose value is even (if the first node has an odd value, then
wait). When the buffer is empty, both should generate a message and wait.
Each of the 4 processes/threads prints the contents of the linked list before and after
it gets access to the linked list. Your output should contain the running result from every
process/thread. You must call <pthread.h> to use pthread create to create a
thread, etc, and you must implement your own protected linked list. Using
an existing library/language which supports protected linked list operations,
e.g. JAVA or C#, is forbidden. (You might need to read the Pthread Programming Handout to learn more about pthread, like how to use mutex in pthread. Due to the
concurrency, if your program got stuck, analyze the reason from the output you have got.)
Date Due: 8:30pm on Thursday, October 20, 2022 (on or before 8:30pm, Oct
20, 2022). Load your source code and output as two separate files on D2L in the folder
Assignment 2, preferably in the form of family name − 2.c and family name − 2.output
(assuming that you are using C).