Giter VIP home page Giter VIP logo

philosopher's Introduction

DINING PHILOSOPHER PROBLEM

왜 설렁탕을 사왔는 데 밥을 먹지 못하니...

  • 다익스트라의 원본 문제와 약간 다릅니다.
  • 그래도 잘 먹어요 얌얌

philo

  • 철학자는 스레드로 생각함

  • 철학자의 왼쪽, 오른쪽에 포크가 존재함.

  • 포크가 복사되는 것을 방지하기 위해 적절한 atomic한 연산을 활용해야 함

  • 철학자는 총 4가지 상태를 가짐

    • 포크를 두개 모두 집을 경우 eating
    • Sleeping
    • 포크를 집기 전까지 Thinking
    • 기아 상태가 사망 시간을 초과하면 Dying
  • 프로그램의 인자는 다음과 같음.

    1. 철학자의 수

    2. 철학자가 굶으면 사망하는 시간

    3. 철학자의 식사 시간

    4. 철학자의 수면 시간

    5. (option) 철학자 하나 당 먹어야 하는 식사 횟수.

      • 모든 철학자가 식사 횟수를 만족하면 시뮬레이션 종료
$ make
$ ./philo 2 410 200 200 2

Philo bonus

  • 철학자는 프로세스로 생각함

  • 포크가 한 가운데에 존재함

  • IPC는 세마포어만 허용됨

  • 이외에는 상단의 허용사양과 같음

$ make
$ ./philo 2 410 200 200 2

철학자를 오래 살리기 위한 팁

  • 터미널에 출력하는 것은 렌더링 타임때문에 늦어진다.

  • 리다이렉션을 통해 파일 입출력을 할 경우 죽지 않고 사는 것을 확인할 수 있다.

$ ./philo 200 410 200 200 > output

philosopher's People

Contributors

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