Code Monkey home page Code Monkey logo

carddrawing_pthread's Introduction

MADE BY NIKOLAJ WASSMANN - S185082

This program is a card drawing game. The game uses 4 threads to draw (2 threads), check (1 thread)
and read (1 thread) the random selected card - therefore it uses multithreading.
The program achives mutual exclusion by using pthread_mutex.


To use the application, simply run it on either your IDEA or using a terminal.

If you are using a terminal, remember to compiler it first, or it won't run.


To check if the threads are working properly, you can try remove the sleep function. If you do so, the program will keep
printing "The selected card has been drawn before, drawing a new one", which means that the system can't reconize which
cards have been drawn and which not.
You can also try to remove one mutex_unlock function, and the program will not continue running, because one of the threads are
locked, and the main thread is waiting for the thread to unlock.
By multithreading the program will run faster, and by using mutal exclusing, the chances of a deadlock is enormously decreased.



CHANGES THAT COULD HAVE BEEN MADE WITH MORE TIME:

When the game is about to end, there are few cards left, its going to take some time. I tried to come up with a fix
for this but without the luck. If you can think of one solution, please describe it in the giving feedback.

carddrawing_pthread's People

Contributors

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