segfaultdoc / haskellmusicalchairs Goto Github PK
View Code? Open in Web Editor NEWThis project forked from segfaultdoctor/haskellmusicalchairs
A multi-threaded solution for a musical chairs simulation in Haskell!
This project forked from segfaultdoctor/haskellmusicalchairs
A multi-threaded solution for a musical chairs simulation in Haskell!
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.