Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement a solution to the Reader - Writer problem with password authentication using threads and semaphores in C programming language on a Linux platform. The
Implement a solution to the ReaderWriter problem with password authentication using threads and semaphores in C programming language on a Linux platform. The program should create two types of threads: reader and writer. Each thread must acquire a unique password from a table to access the database a global variable BUFFER There can be a minimum of and a maximum of readerswriters So any combination of readers and writers is possible, such as or The writers can write a random number in the range to BUFFER, each time it has access to it Let each writerreader sleep second before consecutive writingreading The password table is filled with random digit numbers before use, in the main process. Each readerwriter is allocated a unique password from the table. The shared resource BUFFER should only be accessible after being checked for the password. Furthermore, create equal number of dummy readers and writers with random passwords, not included in the password table. For example, if there are readers and writers, there will be dummy readers and dummy writers. Ensure exclusive access to the password file to prevent race conditions and duplicate passwords. Ensure that readers can access the resource simultaneously with the correct password without interfering with each other. Ensure that writers have exclusive access to the resource with the correct password, preventing simultaneous access by readers or other writers.
Part of Sample Run:
Number of readers:
Number of writers:
Thread No Validityrealdummy Rolereaderwriter Value readwritten
real reader
dummy reader No permission
real reader
dummy reader No permission
real reader
dummy reader No permission
real reader
dummy reader No permission
real writer
dummy writer No permission
real writer
real writer
dummy writer No permission
dummy writer No permission
real writer
dummy writer No permission
dummy writer No permission
real writer
real writer
dummy writer No permission
real reader
real reader
real reader
real reader
dummy reader No permission
dummy reader No permission
dummy reader No permission
dummy reader No permission
real writer
dummy writer No permission
real writer
real writer
dummy writer No permission
dummy writer No permission
real writer
dummy writer No permission
dummy writer No permission
real writer
real writer
dummy writer No permission
real reader
real reader
real reader
real reader
dummy reader No permission
dummy reader No permission
dummy reader No permission
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started