Git Product home page Git Product logo

a-narrow-bridge-synchronization-problem's Introduction

PROBLEM

In a city,there is a two-lane-width one-way-bridge and three one-way roads connected to that bridge. In order to prevent traffic accidents, there are three seperate traffic lamps at the end of the roads (or the connection point of the bridge) as shown in figüre below.

screenshot_1

i) At any time, one of the lamps must be red and the others are green. ii) While the traffic lamp is red, for a new arrival car follow the below instructions; a. if there is no arrival car on one of the other roads, then turn the traffic lamp from red to green and the other lamp green to red. b. else (that means both of the other roads are busy) keep the traffic lamp in red until the number of the waiting cars on the red-lamp road reaches 3, then turn the longest traffic flown road lamp from green to red and waiting road’s lamp red to green. Make sure that you have enough cars, and that they decide to cross the bridge often enough that above two traffic situations can occur. Use one thread to represent one car. Create 60 cars; 20 for each road. Use random method to create cars randomly in 20 seconds. Suppose the length of the bridge is equal to three-car-length and one-car-length speed of a car is 0.5 second.

Screenshot

screenshot_bridge

a-narrow-bridge-synchronization-problem's People

Contributors

saamiberk avatar

Watchers

 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.