Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
/ ReadersWriters Public archive

This repository contains the solution to the assignment that was assigned to me in the course CSE316 during my 4th semester.

Notifications You must be signed in to change notification settings

boorah/ReadersWriters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Question

Write a multi-threaded C program that gives readers priority over writers concerning a shared (global) variable.

Essentially, if any readers are waiting, then they have priority over writer threads

  1. Writers can only write when there are no readers.

This program should adhere to the following constraints:

  1. Multiple readers/writers must be supported (5 of each is fine)
  2. Readers must read the shared variable X number of times
  3. Writers must write the shared variable X number of times
  4. Readers must print:
    i. The value read
    ii. The number of readers present when value is read
  5. Writers must print:
    i.The written value
    ii. The number of readers present were when value is written (should be 0)
  6. 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.       

About

This repository contains the solution to the assignment that was assigned to me in the course CSE316 during my 4th semester.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages