Giter VIP home page Giter VIP logo

urbinolaundromat's Introduction

Urbino Laundromat

Progetto in Haskell per il corso di "Linguaggi di programmazione e verifica software"

  • Project specification

    Urbino laundromat is now equipped with N concurrent automated stations working as follows. As a customer enters, she chooses a station and puts a coin into the related slot to gain a token enabling a given available washing machine. In order to properly allocate the washing machines, the stations share a boolean array available[NMACHINES], where NMACHINES is a constant indicating how many machines there are in the laundromat, and a semaphore nfree that in- dicates how many machines are available. The pseudo-code executed by each station to allocate a machine and, therefore, issuing a token, is:
    int allocate() 
    {
      P(nfree); /* Wait until a machine is available */
      for (int i=0; i < NMACHINES; i++)
          if (available[i] == TRUE) {
              available[i] = FALSE;
              return i;
      }
    } 
    

    [Reminder: the semaphore is equipped with two proper atomic operations, historically denoted as P and V: the former decrements the semaphore, while the latter increments it. The domain of possible values for the semaphore is [0..NMACHINES].] After having obtained the token, the customer puts laundry into the al- located machine and inserts the token into the machine. When the machine finishes its cycle, it informs the central computer that it is available again. The central computer has access to the same information shared by the stations and executes the following pseudo-code to release machines:

    void release(int machine) /* Releases machine */
    {
      available[machine] = TRUE;
      V(nfree);
    } 
    

    The available array is initialized to all true, and the semaphore nfree is initialized to NMACHINES. Model such an asynchronous system and verify the properties of interest for the success of the laundromat.

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.