473,568 Members | 2,939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

readwrite lock with read reentrant

This is not a C++ specific issue. However, I am trying to implement a
readwritelock in C++ and hence would like to get help from this
group.

a readwritelock allows shared lock among all readers and exclusive
lock for a single writer. After implemented, I realized that the
writer may suffer starvation: readers can continuously get shared lock
and hence writer will wait indefinitely. so I added a writer wait
count and prevent reader acquiring shared lock as soon as a writer is
waiting. But this has serious issue: it prevents reader reentrant: a
reader already has shared lock should be able to get shared lock
again. Without reader reentrant, a reader and a writer will deadlock.

Any advice on how to resolve this issue: a writer cannot starve and
reader can reentrant?

Thanks.

Jul 23 '07 #1
1 2736
jj_online wrote:
This is not a C++ specific issue. However, I am trying to implement a
readwritelock in C++ and hence would like to get help from this
group.

a readwritelock allows shared lock among all readers and exclusive
lock for a single writer. [..]
Try comp.programmin g.threads. Your issue is not related to C++ at
all and as such OT here, sorry.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3745
by: Adrian Parker | last post by:
For some reason when I call validateFields before .Update (see below), I get this error: "Consumer's even handler called a non-reentrant method in the provider" However if I comment out the call to validateFields, all is fine. What could possibly cause this error? What is a non-reentrant method?
6
11036
by: junky_fellow | last post by:
what are reentrant functions? What are the characteristics of a reentrant code ? what things should be kept in mind while writing a reentrant code ?
3
2655
by: Invalid | last post by:
I launch a worker thread that periodically reads a volatile bool abortRequested, which could be set to true by my main form. IOW, there is one thread that can read that bool and one different thread that can set it. See code below for an overview. In a C or C++ environment, my current approach would be adequate (no need to acquire...
2
2836
by: TheOne | last post by:
Would anyone please point me to a list of reentrant GNU C/C++ library functions? I have searched a lot on the web for it but without any success. Man page of signal(2) has listed system calls (POSIX 1003.1-2003 list) which are safe(reentrant) but thats not sufficient for my purpose. Thanks in advance.
9
8280
by: TheOne | last post by:
Would anyone please point me to a list of reentrant C library functions? I want to know which C library functions are safe to use inside a signal handler across all platforms. Does GNU C library make few other functions reentrant on Linux platform? I have searched a lot on the web for it but without any success. Man page of signal(2) has...
17
1995
by: djc | last post by:
I got great info on related question previously. This link <http://www.yoda.arachsys.com/csharp/threads/volatility.shtml> from Brian Gideon was especially informative. 1) the lock statement does *not* make the processor finish all code in the code block before giving another thread from your process a slice of processor time, it only makes...
94
30232
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock Statement (C# Reference) statement to serialize access. " But when is it better to use "volatile" instead of "lock" ?
17
3243
by: fmassei | last post by:
Dear all, I'm trying to put some old code in a portable, cross-platform library and I'm facing a big problem: is there a standard, platform- independent way to write a reentrant function that allocate dynamic memory? In other words: is it safe to use malloc() or free() in a thread-safe function? Thank you, Francesco
12
3465
by: Bit Byte | last post by:
I am modifying some legacy code, to make the functions reentrant. I use lots of global data (large nested structs) to pass data around quicky. The global structures are far too large (in size) for each of my functions to maintain copies. Any suggestions on the best way to write a reentrant version of my library? - bearing in mind that my...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.