Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tanmay-312/sleeping-barber-go
Sleeping barber problem of system design
https://github.com/tanmay-312/sleeping-barber-go
backend concurrency golang mutex-synchronisation operating-system real-life-problems sleeping-barber system-design system-programming
Last synced: about 1 month ago
JSON representation
Sleeping barber problem of system design
- Host: GitHub
- URL: https://github.com/tanmay-312/sleeping-barber-go
- Owner: Tanmay-312
- Created: 2024-04-04T09:23:56.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-04T09:29:41.000Z (9 months ago)
- Last Synced: 2024-04-04T10:34:27.228Z (9 months ago)
- Topics: backend, concurrency, golang, mutex-synchronisation, operating-system, real-life-problems, sleeping-barber, system-design, system-programming
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sleeping-Barber-GO
The sleeping barber problem is a hypothetical situation that mirrors real-world concurrency challenges in system design and development. The problem involves a barber shop with one barber, one barber chair, and a waiting room with chairs for the customers. The barber sleeps when there is no customer in the waiting room. When a customer arrives, the barber is woken up and cuts the customer's hair. If there are no empty chairs in the waiting room when a customer arrives, the customer leaves.
The ClientsChan channel is used to communicate between the clients and the barber. The barber process receives a customer from the channel and cuts their hair. If there are no customers in the channel, the barber waits. The customer process sends their id to the channel and waits for the barber to finish cutting their hair.
This solution ensures that the barber is always woken up when a customer arrives and that customers are never left waiting if there are empty chairs in the waiting room.
Here are some additional details about the sleeping barber problem:
1. The problem is often attributed to Edsger Dijkstra, one of the pioneers in computer science.
1. The problem is a classical problem of process synchronization.
1. The problem is not just a theoretical puzzle; it mirrors real-world challenges in system design and development.
1. The problem can be solved using a variety of different methods, including semaphores, mutexes, and channels.
1. The problem is a good example of how to use concurrency to solve a real-world problem.