https://github.com/takp/priority-readers-and-writers
multi-threaded C program which gives readers priority over writers
https://github.com/takp/priority-readers-and-writers
Last synced: 3 months ago
JSON representation
multi-threaded C program which gives readers priority over writers
- Host: GitHub
- URL: https://github.com/takp/priority-readers-and-writers
- Owner: takp
- Created: 2018-09-16T04:19:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-16T07:01:15.000Z (over 6 years ago)
- Last Synced: 2024-12-27T09:27:56.881Z (5 months ago)
- Language: C
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# priority-readers-and-writers
This is a multi-threaded C program that gives readers priority over writers concerning a shared (global) variable, based on the lecture from Udacity's "Introduction to Operating Systems".
## Constraints
Essentially, if any readers are waiting, then they have priority over writer threads --
writers can only write when there are no readers. This program should adhere to the
following constraints:- Multiple readers/writers must be supported (5 of each is fine)
- Readers must read the shared variable X number of times
- Writers must write the shared variable X number of times
- Readers must print:
- The value read
- The number of readers present when value is read
- Writers must print:
- The written value
- The number of readers present were when value is written (should be 0)
- Before a reader/writer attempts to access the shared variable it should wait some random amount of time
- Note: This will help ensure that reads and writes do not occur all at once
- Use pthreads, mutexes, and condition variables to synchronize access to the shared variable