Question: 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 Reader-Writer 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 1 and a maximum of 9 readers/writers. So, any combination of readers and writers is possible, such as (1,1),(1,2)...(1,9),(2,1)...(9,1),..., or (5,5). The writers can write a random number in the range 0-9999 to BUFFER, each time it has access to it. Let each writer/reader sleep 1 second before consecutive writing/reading. The password table is filled with 10 random 6-digit numbers before use, in the main process. Each reader/writer 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 2 readers and 3 writers, there will be 2 dummy readers and 3 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: 4
Number of writers: 6
Thread No Validity(real/dummy) Role(reader/writer) Value read/written
1 real reader 0
1 dummy reader No permission
2 real reader 0
2 dummy reader No permission
3 real reader 0
3 dummy reader No permission
4 real reader 0
4 dummy reader No permission
1 real writer 979
1 dummy writer No permission
2 real writer 4793
3 real writer 7455
2 dummy writer No permission
3 dummy writer No permission
4 real writer 4454
4 dummy writer No permission
5 dummy writer No permission
5 real writer 1250
6 real writer 3857
6 dummy writer No permission
1 real reader 979
2 real reader 4793
3 real reader 7455
4 real reader 4454
1 dummy reader No permission
2 dummy reader No permission
3 dummy reader No permission
4 dummy reader No permission
1 real writer 1160
1 dummy writer No permission
2 real writer 1658
3 real writer 1691
2 dummy writer No permission
3 dummy writer No permission
4 real writer 7238
4 dummy writer No permission
5 dummy writer No permission
5 real writer 6350
6 real writer 5839
6 dummy writer No permission
1 real reader 1160
2 real reader 1658
3 real reader 1691
4 real reader 7238
2 dummy reader No permission
3 dummy reader No permission
4 dummy reader No permission

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!