Watch cars make their way through a 4-way intersection, by "claiming" the quarters of the intersection they need to cross to make it to the direction they want to go. If a quarter is already claimed, a car will wait before driving onto the intersection. This way, several cars can cross at once, but they won't lock up or crash. * click the traffic signs to change the directions cars can turn * When a car "claims" a quarter, it is highlighted in the same color. * You can see where the cars want to go by looking at the blinkers/turn signals in the headlights. * adjust the slider to increase/decrease traffic
Computer programs often need to share files/memory/processors/... like these cars need to share space on the intersection. Computer Scientists use a very similar locking mechanism called "semaphores" to keep their programs from crashing (just like the cars). It was invented by the Dutch mathematician and computer scientist Edsger Dijkstra in the early 1960s. I came across this post on StackOverflow, and thought it'd be fun to try and implement it in Scratch. The wording is complicated, but here's the link anyway: https://stackoverflow.com/questions/9404484/traffic-intersection-simulation-using-multi-threading-algorithm The road signs are SVG's from WikiMedia: https://commons.wikimedia.org/wiki/Category:SVG_road_signs I drew everything else in Scratch :)