Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2004

Tip: Looking for answers? Try searching our database.

ReadersWritersLock in an unmanaged C++ program.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MJS_Jeff - 29 Sep 2004 15:13 GMT
Folks, I have posted this message on a different newsgroup but I did not get
a single response.  I take it that it must not have been the right forum.  
Anyways.

I am seeking the solution to the classic ReadersWritesLock with a slight
twist in My unmanaged C++. I can not import "System" and "System.Threading"
namespaces.

I need to use some kind of lock (semaphore, Mutex, or any other
alternative), among threads to alow multiple threads to use the shared
resource.  
The threads will have either the "Reader" role or the "Writer" role.
As long as a the thread is a "Reader",  and no "Writer" thread is holding
the lock or
waiting on the lock  the Reader thread can proceed.  
Multiple "Readers" can access the resource while there is no Writer.
Once a Writer enters the queue for the Wirte access, no new Reader will be
allowed to get the lock and it will encounter a timeout reject return value.  
However, every previously entered Reader is allowed to complete its
operations until all releases its lock.  
When no more Reader is pending, the Writer starts its
operation at the end of which it and then releases the lock.  At this time
new Readers will be successfull in aquiring the lock.
When the first Writer thread is pending or working, all subsequent Readers
and/or Writer threads shall get the timeout rejection.

I have looked into documents for Semaphore, Mutext and "Wait Operations" but
I am not sure the semaphore's count-down can help me implementing the
algorithm.

Any Ideas and suggestions is greatly appreciated.
Signature

--Jeff

Mihajlo Cvetanovic - 29 Sep 2004 15:32 GMT
> I am seeking the solution to the classic ReadersWritesLock with a slight
> twist in My unmanaged C++. I can not import "System" and "System.Threading"
[quoted text clipped - 3 lines]
> alternative), among threads to alow multiple threads to use the shared
> resource.  

I found this while googling with <reader-writer c++ synchronization>:
http://www.frostbytes.com/~jimf/papers/c++sync/c++sync.html

Maybe "Fair-Share Readers/Writer Class" is what you need.
MJS_Jeff - 29 Sep 2004 15:45 GMT
Thanks Mihajlo.
I will look in the articles.  They appear to be informative.

--Jeff

> > I am seeking the solution to the classic ReadersWritesLock with a slight
> > twist in My unmanaged C++. I can not import "System" and "System.Threading"
[quoted text clipped - 8 lines]
>
> Maybe "Fair-Share Readers/Writer Class" is what you need.
Vladimir_petter - 29 Sep 2004 19:14 GMT
"MJS_Jeff" <MJS_Jeff@discussions.microsoft.com> wrote in message
> Any Ideas and suggestions is greatly appreciated.

Take a look at "Programming Applications for Microsoft Windows" book by
Jeffrey Richter
Chapter "Thread Synchronization Toolkit"

Vladimir.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.