Starting from:
$35

$29

Homework #7 Solution

Write a program that creates a doubly‐linked circular linked list of length 27. The linked list MUST be developed using pointers (not an array‐based linked list). The data contained by the linked list will be a simple integer.




The program must also create 8 threads:




The first
four
threads
are producers
that navigate the linked
list
in a
clockwise order and that write an integer (of increasing
value 1,
2, 3,
to N) to each link as
they are encountered. I.e.
read
the
current value
and increment
it by 1.



The remaining four threads are consumers that navigate the linked list in a counter‐clockwise order and that read the integer data from each link and that prints the link number and integer data on the screen. I.e.




Link #n <tab Data x




These threads will also decrement the data vaue found by 1.




The problem here is that we have a data oriented critical section problem (not a code oriented critical section problem) and you must devise and implement a method to prevent any lost updates.




Notes:

‐‐‐‐‐‐

 
You cannot use pthread_join to artificially start and stop the threads.




 
You cannot restart the threads once that have been started.




REQUIREMENTS:

‐‐‐‐‐‐‐‐‐‐‐‐‐

 
Your program must run in Streibel 109.




 
Your full name must appear as a comment at the beginning of your program.




 
Your source code must be named hw7‐yourname.c or hw7‐yourname.cpp




 
Email your source (subject hw7‐yourname) to rmarsh@cs.und.edu



More products