Giter Club home page Giter Club logo

operatingsystems-cs33211-ksu-project1's Introduction

Programming Assignment 1 - Producer & Consumer Problem


Author: Elliott Hager

Fall 2023 Semester

CS-33211: Operating Systems

Dr. Qiang Guan

Kent State University



Description (Provided from the assignment instructions)

The producer generates items and puts items onto the table. The consumer will pick up items. The table can only hold two items at the same time. When the table is complete, the producer will wait. When there are no items, the consumer will wait. We use semaphores to synchronize producer and consumer. Mutual exclusion should be considered. We use threads in the producer program and consumer program. Shared memory is used for the “table”.



Implementation

Both the producer and consumer have their own processes, with a thread in each created and pointed to a function of the same name (i.e. consumer and producer respectively). With each thread running their own functions, a shared memory buffer with a capacity to hold two items is shared between the producer and consumer. To help prevent deadlock and other data hazards when it comes to a shared buffer, a semaphore is used to indicate use of the buffer. The number '1' indicates the buffer is currently in use, while the number '0' indicates the buffer is available for use.s



Compilation

Both the producer and consumer are septate files and meant to be septate processes. There are three options within the make file. The first two being consumer and producer respectively. These compiler the producer and consumer. The last option is clean, which cleans any object (.o) files as well as the compiled program files to be executed.

Running the consumer and/or producer separately will not be of benefit as each relies on each other to run concurrently.


Consumer:

The following make command will compile the consumer files for execution

    make consumer

Producer:

The following make command will compile the producer files for execution

    make producer

Run:

The following make command will compile the producer, consumer, and run both with the shared memory key of shmfile

    make run

Clean:

The following make command will remove the compiled and executable program files

    make clean



Run Instructions:

To run both of the producer and consumer at the same time, for Linux and Unix systems, there are two options.

1.) Manually/Command

    ./out/consumer shmfile & ./out/producer shmfile

2.) Using Make (Preferred)

Using the make run command will compile and run both the producer and consumer. This is the preferred method of compilation and running the project.



Documentation:

Please see the Doc folder for a PDF manual/documentation packet.



Libraries & Tech Stack

  • C++
  • Make
  • G++
  • PThread Library
  • SharedMem 3 Library

operatingsystems-cs33211-ksu-project1's People

Contributors

ehag-fru avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.