Giter Site home page Giter Site logo

a-parfenov / philosophers Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 1.61 MB

In this project, I studied the basics of threading a process. How to create threads, how to work with mutexes.

Makefile 6.32% C 93.68%
philosophers 21school basics-of-threading-a-process

philosophers's Introduction

Philosophers

In this project, I studied the basics of threading a process. How to create threads, how to work with mutexes.

This is taken from the subject.pdf.


To run the simulation a few variables are needed:

  1. number_of_philosophers: is the number of philosophers and also the number of forks.
  2. time_to_die: is in milliseconds, if a philosopher doesn’t start eating ’time_to_die’milliseconds after starting their last meal or the beginning of the simulation,it dies.
  3. time_to_eat: is in milliseconds and is the time it takes for a philosopher to eat. During that time they will need to keep the two forks.
  4. time_to_sleep: is in milliseconds and is the time the philosopher will spend sleeping.
  5. number_of_times_each_philosopher_must_eat: argument is optional, if all philosophers eat at least ’number_of_times_each_philosopher_must_eat’ the simulation will stop. If not specified, the simulation will stop only at the death of a philosopher.

Usage

To compile the programm run make all in the root of the project.
Then run ./philo with the parameters you want to test explained

i.e.: ./philo 4 410 200 200 4
Now the simulation will start and run until each philosopher has eaten 4 times or dies.

This ./philo 4 410 200 200 should theoretically run infinite.
If you want to see the usage while using you can do ./philo and it will show you the correct usage.

philosophers's People

Contributors

a-parfenov avatar

Stargazers

 avatar  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.