[Solved] CSE 330 Operating Systems Project #3

$25

File Name: CSE_330__Operating_Systems_Project_#3.zip
File Size: 348.54 KB

SKU: [Solved] CSE 330 – Operating Systems Project #3 Category: Tag:
5/5 - (1 vote)

Implementing Semaphores

Using the threads, you have implemented, implement semaphores. Since the threads are nonpreemptive, you do not need to ensure atomicity of the semaphores (they are already atomic).

Implement the following: (in a file called sem.h)

  1. Semaphore data structure: A value field and a queue of TCBs.
  2. InitSem(semaphore, value): Initializes the value field with the specified value.
  3. P(semaphore): The P routine decrements the semaphore, and if the value is less than zero then blocks the process in the queue associated with the semaphore.
  4. V(semaphore): The V routine increments the semaphore, and if the value is 0 or negative, then takes a PCB out of the semaphore queue and puts it into the run queue. Note: The V routine also yields to the next runnable process. //this is important.
  5. Implement a solution to the Producer Consumer Problem with the following settings:

There are three producers all in infinite while loops each producing 1 item in one loop.

There are three consumers all in infinite while loops each consuming 1 item in one loop.

Every consumer or producer yields at the end of a loop to the next process.

Consider that the buffer size is 6 items.

Consider that in your ready queue there are three consumers then seven producers then 7 consumers and finally three more producers .

Run the code for infinitely long.

At the end of each loop before yield the consumer should print the following: if consumer X is consuming an item then print

This is consumer X consuming item generated by producer Y else print

Consumer X is waiting

At the end of each loop before yield the producer should print the following:

if producer X is producing an item then print This is producing X producing item number Y else print

Producer X is waiting

Submission and Grading:

Your project must consist of 4 files

  1. h (uses ucontext.h)
  2. h (includes TCB.h)
  3. h (includes q.h)
  4. h (includes threads.h)
  5. proj-3.c (includes threads.h) must contain your name(s) in comments @ beginning (make sure the compile command, gcc proj-3.c does the correct compilation).

All 5 files are to be ZIPPED into one zip or gzip file and uploaded in Canvas. The name of this file should reflect the name of the student (abbreviated, do not make it too long).

Note: Grading is on Ubuntu. It is in your interest to make sure the program compiles and runs in the target test platform.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE 330 Operating Systems Project #3
$25