Starting from:
$30

$24

CSC Lab 6: Process Synchronization Solution

Problem Description

Consider a system with 3 smoker processes and 1 agent process. Each smoker continuously rolls a cigarette and then smokes it. The smoker needs three ingredients: tobacco, paper, and matches. One of the smokers has paper, another has tobacco, and the third has matches. The agent has an infinite supply of all three materials and (randomly) places two of the ingredients on the table each time. The smoker who has the remaining ingredient then makes and smokes a cigarette, signaling the agent on completion. The agent then puts out another two of the three ingredients, and the cycle repeats.

Task: Write two programs to synchronize the agent and smoker processes: one using semaphores and another using pthread libraries.

Instructions

        ◦ Please see this link for pseudocode: http://www.cs.umd.edu/~hollings/cs412/s96/synch/smokers.html
    • Though the description says the agent process can infinitely supply two of the three ingredients, you can assume that the agent places ingredients only a finite number of times, say for example 10.

        ◦ You need to use the “sem.h” header file in your semaphore-based solution.

        ◦ Write a brief report on how your solution synchronizes the four processes. The C solution files must be internally documented.



Marks:

Semaphore solution : 15

pthread libraries solution: 15

Report: 10
Submission Instructions

    • All the programs MUST be clearly indented and internally documented

    • Make sure your programs compile and run without any errors

• Only include c files or txt files for submission. Do not include any    executables.

    • Save all your programs with meaningful names and zip into a single folder as: Lab6_[your last name here].zip (e.g., Lab6_Xyz.zip)

    • Email your code with the subject line, "Task6-CSC33200–Section H(41576)-lastname"

    • Email: sdebnath@ccny.cuny.edu

******


Office Hour: Thursday 11:00 AM – 12:00 PM

Zoom Link: https://ccny.zoom.us/j/82938095199

Meeting ID: 829 3809 5199
One tap mobile
+16465588656,,82938095199# US (New York)
+13126266799,,82938095199# US (Chicago)
Dial by your location

+1 646 558 8656 US (New York)
+1 312 626 6799 US (Chicago)
+1 301 715 8592 US (Washington DC)
+1 253 215 8782 US (Tacoma)
+1 346 248 7799 US (Houston)
+1 669 900 6833 US (San Jose)

Meeting ID: 829 3809 5199
Find your local number: https://ccny.zoom.us/u/kMs03gJtK

IMPORTANT NOTE: Please connect with zoom with a valid CCNY or CITYMAIL email id. Please sign up with the CITYMAIL or CCNY email address at :

https://www.ccny.cuny.edu/it/zoom

More products