GithubHelp home page GithubHelp logo

hariharan-sv / producer_consumer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 136 KB

Visualizing Producer-Consumer problem as a photocopy centre where clients are producers and printers are consumers

C 94.19% C++ 5.81%
c producer-consumer printer-sharing simulation printer process-synchronization heisenbug printers insert-data

producer_consumer's Introduction

Producer_Consumer

Visualizing Producer-Consumer problem as a photocopy centre where clients are producers and printers are consumers

About the Files

Here a circular queue is stored inside the shared memory These programs will be working with shared memory

The repo has three main files

  • main.c - creates shared memory
  • client.c - inserts data into shared memory
  • devices.c - views and deletes data from shared memory

and three additional files which provides support to above main files

  • circular_queue.c - has functions to work with Circular Queue
  • circular_queue.h - has Circular queue's structure
  • photocopy.h - has Photocopy's structure

Working

The Circular queue structure has an array of Photocopy structure. Main program creates a queue for a store and the program will run for the time mentioned as a cmd arg. Client program inserts data into queue. Devices program views the queue and does nothing when the queue is empty, else it simulates printing the data for a specified time and deletes data if time elapsed is 0. All programs will terminate if main program for a store terminates. (i.e) Only a store has a queue, if there is no store then there will be no queue for a closed store.

Run the files

Execute in this order To create a queue

./main -t <total_run_time> -n <no_of_printers> -l <length_of_queue>

it will return key for store and queue. use it in next 2 programs.

To view and work with the queue.

./devices -s <store's_key> -q <queue's_key> -b <max_break_time> -w <max_work_time>

To insert data into the queue.

./client -s <store's_key> -q <queue's_key> -n <no_of_copies> -p <no_of_pages> -f <file_name>

Problem in the code

The code has a rare type of bug known as Heisenbug. The program seems to work perfect when debugger is turned on and crashes when it is turned off ( for more details about Heisenbug click here )

producer_consumer's People

Contributors

deepannarayanamoorthy avatar hariharan-sv 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.