Git Product home page Git Product logo

sleeping_ta's Introduction

Sleeping_TA

Use pthreading to imitate a real life scenario of a TA who’s sleeping in his room, waiting for students to ask questions.

The TA remains sleeping until a student comes and wake him up. There are 3 waiting chairs outside his room. If the student came and found the 3 chairs are taken, then they should come back in a later time, else he will wait for the TA to finish with the one inside.

Each student and the TA is represented by a separate thread. Also, there are 3 semaphores representing each chair, a semaphore representing the state of the TA whether sleeping or not, a mutex representing whether the TA chair is being used by a student or not, and a semaphore representing whether the TA is done helping a student or not.

Each student goes to do the programming assignment for a random amount of time then comes to ask the TA questions.

HOW TO RUN FOR TESTING?

//go to directory where the c file is located

//compile c code

gcc -pthread Sleeping_TA.c

//run executable

./a.out

sleeping_ta's People

Contributors

shehabeldeenibrahim avatar

Watchers

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