Skip to content

Solution for Doctor on Night Duty problem using semaphores and mutexes

License

Notifications You must be signed in to change notification settings

bcanozter/Doctor-on-Night-Duty-Problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Table of contents

General info

Create N patients using PThreads, with each patient running as a separate thread. The doctor runs as a separate thread as well. Patient threads will alternate between having coffee in the cafeteria and being treated by the doctor. If the doctor is available, they will be treated immediately. Otherwise, they will either sit in a chair in the waiting room or, if no chairs are available, will go back to the cafeteria for a random amount of time and will return to see the doctor at a later time. If a patient arrives and notices that the doctor is taking a nap, the patient must notify the doctor using a semaphore. When the doctor finishes treating a patient, she must check to see if there are patients waiting for help in the waiting room. If so, the doctor must help each of these patients in turn. If no patients are present, the doctor may return to napping.

Technologies

Project is created with:

  • XCode version: 10.2.1

Compiling

To compile this software you must use a gcc terminal.

  1. Open the bash terminal
  2. To compile, $ g++ --std=c++11 -o run.out main.cpp
  3. To run, ./run.out

Preview

Author

About

Solution for Doctor on Night Duty problem using semaphores and mutexes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages