Code Monkey home page Code Monkey logo

haskellmusicalchairs's Introduction

1. The shared resource that represents music is an MVar of type bool. Line 61 the emcee turns on the music. Line 132 is where the music is turned off. I use a list of MVar bools. GenerateChairs function is called at line 82 and the function declaration begins at line 173. True represents and empty chair.

2. Each player thread recursive loops in the sitinchair function, each iteration checking if the chair is empty. If it is it sits. If not it recurses, if it never sits and there are no chairs left, then the player failed to sit. By looping through the list I ensure each chair is attempted to be sat in, and one thread is guaranteed to sit.

3. There was competition for chairs and the strings to be printed. Each thread fought for a the chair resources. The challenging part was getting the emcee to coordinate the music alongside the players. Once I figured this out, it was clear to me how the multithreading worked.

4. Being a concurrency project not much was straightforward, except for the overall design, since we already did this project in Java.

5. Deadlocks were hard to debug, but once I realized that the printing was causing the deadlocks. The way I debugged this was by commenting out certain print statements and figuring out which comments would allow the program to continue execution. I would also place print statements in places to figure out where the program would hang. 

haskellmusicalchairs's People

Contributors

segfaultdoc avatar

Watchers

James Cloos 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.