read writers problem, C/C++ Programming

Readers Writers with Processes and Threads
Write two programs implementing ``reader pritority readers-writers synchronization'''' on files. One program will use processes, created with fork(), and synchronized with semaphores. The other program will use threads, created with pthread_create(), and synchronized with mutexes and conditions. In the following, the word "process" is used to describe either a process or thread, as appropriate.
Your program will create two readers and two writers. All four will access a common file, named ``SharedFile.'''' This file should contain a single number. The file should be created and given an initial value of 0 before the processes/threads are spawned.
The reader pseudocode:
repeat 20 times:
acquire read lock
read the number from SharedFile
release the read lock
print a message identifying the process, and the value read from SharedFile
sleep for a random period between 100 and 200 msec
The writer pseudocode:
repeat 20 times:
acquire write lock
read the number from SharedFile
increment it by a random value between 1 and 6
write the new value to SharedFile
release the write lock
print a message identifying the process, and the value written to SharedFile
sleep for a random period between 100 and 400 msec
Submit ONLY your C/C++ source code. Be sure to put your name and course in the comment header. The code must run on the "algebra and friends" machines. Use good programming style (comments, indentation, meaningful identifiers, etc.)
Posted Date: 1/21/2013 3:44:48 PM | Location : United States







Related Discussions:- read writers problem, Assignment Help, Ask Question on read writers problem, Get Answer, Expert's Help, read writers problem Discussions

Write discussion on read writers problem
Your posts are moderated
Related Questions
C program to check display days and month main() {           int months, days;           clrscr();           printf("ENTER DAYS: ");           scanf("%d", &days);

We are now quite happy to use the basic mathematical expressions, however in engineering we use scientific functions i.e Sin , Cos  , ln etc . Within C we have the following functi

a program to accept average, if average is 75 to 85 print it out else bypass using counter. enter and process 5 records

Convert compass heading in degrees (0-360 degrees)to compass bearing. A compass bearing consist of three items namely: a.The direction you face (North or South) b.An angle betwe

Create a program to print a battleship grid to the console and mark squares as destroyed

Requirements: 1.  This assignment as well as other assignments in this class must be finished on Windows operating system. 2.  Zip your program and submit the zip file on ANG

What is the difference between structure and class? - Members of structures are public while those of a class are private. - Classes provide data hiding while structures don

how to make a game

You must write a program that can both decrypt and encrypt a single word that is entered by the user. The initial choice of encryption and decryption is left up to the user. Addi