|
|
1.1 ! root 1: Summary: ! 2: ! 3: This article refers to the file Database.c which is one ! 4: variation of the classical synchronization problem ! 5: Reader/Writers. The Reader/Writer problem first stated and ! 6: solved by Courtois revolves around a shared resource a DataBase ! 7: typically. The issue here is to allow both readers and writers ! 8: access to the database without corrupting it. Typically one allows ! 9: multiple Readers to access the database as long as a Writer is not ! 10: in there. However when a Writer is in the database no one else is ! 11: allowed in either Reader or Writer. There are several variations ! 12: of this problem around the simplest will favor Readers to the ! 13: exclusion of Writers or visa versa. ! 14: ! 15: The implementation I used I believe was modeled after Dijkstra; ! 16: however I've long since misplaced my operating systems book so can't ! 17: verify it. His method would allow as many readers in the database ! 18: at one time until a Writer wished entrance in. Then no other Reader ! 19: can enter the database until this Writer is finished. All Readers ! 20: currently in the database however can finish. This way no starvation ! 21: of either the Readers or Writers which is inherent in the simpler ! 22: methods will happen. ! 23: ! 24: More Information: ! 25: ! 26: In order to keep this sample focused, I've left the user interface ! 27: simple; to run this sample at the command prompt type ! 28: ! 29: ReadWrit ! 30: ! 31: What you will see are the values the Readers put on the screen. These ! 32: are the running total of the threads that wrote to the database. ! 33: ! 34: Enjoy
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.