https://github.com/jacintogomez/concurrency-control
Using locks to prevent race conditions in operating systems
https://github.com/jacintogomez/concurrency-control
concurrency-control mutex operating-systems semaphores spinlock
Last synced: 9 months ago
JSON representation
Using locks to prevent race conditions in operating systems
- Host: GitHub
- URL: https://github.com/jacintogomez/concurrency-control
- Owner: jacintogomez
- Created: 2023-12-11T15:41:56.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-11T17:08:33.000Z (over 2 years ago)
- Last Synced: 2025-03-30T07:17:36.267Z (over 1 year ago)
- Topics: concurrency-control, mutex, operating-systems, semaphores, spinlock
- Language: C++
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Concurrency-Control
`concurrency.cpp` shows how an unsynchronized threaded program will print when no locks are placed around the print statements. The "proper" output of this code is below:

But that will not be printed as the threads will compete for the value of the num variable and access to the console. Realistically you'll see something more like
this when running `concurrency.cpp`:

The provided files `spinlock.cpp`, `mutex.cpp`, and `semaphore.cpp` show how the correct printing can be achieved by placing a lock around the `printmanylines()` function.
This ensures that the blocks of numbers finish printing before allowing another thread to print its num.