An open API service indexing awesome lists of open source software.

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

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:

Screenshot 2023-12-11 at 12 06 27 PM

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`:

Screenshot 2023-12-11 at 12 05 50 PM

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.