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
Describe what is actual arguments? - When certain functions are created and used to perform an action on some provided values, some values are required to be passed to them. Th

Draw a circle in c program: void main() { clrscr(); int i,r=50,t,j,x,y; int gd,gm; gd =DETECT; initgraph(&gd,&gm,""); for(x=50;x for(y=50;y {   i

Create a class Word, representing a word. Two words should be considered equal if they consist of the same sequence of letters and we consider upper case and lower case as equal. F

write a c++ program, that finds the minimum total number of shelves, including the initial one, required for this loading process.



Need FTP Upload and MySQL Project Description: We are in need of an executable application that will be execute as a scheduled task on Windows Server 2008 R2 and can perform

how to create the programs in c++ knowledge

to compute the net pay of an emplyee, given his/her pay rate, number of hours and tax rate

write a java program padovan string program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class Pado