Prj5 - Optional Phase 3
Prj5 - Optional Phase 3
Prj5 - Optional Phase 3
Objectives:
• To develop a producer consumer application under race conditions.
• To design an application that overlaps its I/O and computing operations.
References:
• Linux man pages “man pthreads” , “man sem_overview” and https://man7.org/linux/man-pages/
• Lawrence Livermore National Laboratory Computing Center POSIX Threads Programming | LLNL HPC Tutorials
• Linux System Programming 2d ed., Robert Love, O’Reilly 2013 (CATS/CSE5031 – Home / Resources / References)
• The GNU C Library Reference Manual (http://www.gnu.org/software/libc/manual/pdf/libc.pdf )
A.1 Definition
This project is the optional Phase 3 of Project 5. It aims to reimplement the producer-consumer scenario you have
developed in the compulsory:
i) under race conditions, that is, producer & consumer threads:
+ communicate using bounded buffers;
+ modify/access shared variables.
ii) overlapping its I/O and computing operations using 3 worker threads input – compute – display to provide
the time line depicted here after.
i) The “event” and “mutex” semaphores that are used to coordinate each producer & consumer pair and their
initialization are summarized here after.
ii) Synchronization algorithms implemented by producer & consumer pairs are summarized here after.
Note that:
✓ Transactions ① and ② coordinate for the provision and the release of the shared buffer
✓ Producer & consumer protect their access to critical sections using mutual exclusion semaphores.
✓ Consumer does not block itself to wait for a record to be produced using “sem_wait” primitive.
An event that might never happen! If the producer ends.
Consumer uses the conditional “sem_trywait” primitive to avoid its blocking if the event has not been
posted, skips the computation to check if the producer is terminated or not.
iii) Refer to the above framework to analyze in the reference program how the producer and consumer pairs”
✓ “input – compute” and
✓ “compute - display”
are coordinated and manage race conditions.
ii) Store compressed report in the Prj5-BONUS:CSE5031-group# folder located under Assignments heading
at the CATS course portal CSE5031 OS.