473,770 Members | 5,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Thread Safe bug-hunt...

Hi all,
I've got my self a bug that I am out of ideas on how to fix...
A section of my program launches a thread to handle a FIFO work buffer,

I make the fifo as a single link list, the head node is set to NULL
when the buffer is empty by the handler thread.

One or more ( typicaly 3 or 4 ) request threads are used to place
objects on to the work que.

Both the request and handler threads wait to establish ownership of a
mutex lock before adding to or freeing from the que.

The bug shows up when one of the request threads finds the work que
empty and adds it request. occasionaly the request gets clobbered by
one of the other threads.

I suspect the mutex lock is not working correctaly, but I have tested
it and can see threads having to wait for the lock ( both using gdb and
simple prints ), so I am at a loss of how a request could be getting
clobberd.

The suspect code from the handeler is:

while( epicsMutexLockO K != epicsMutexLock( *lock) ){
epicsThreadSlee p(0);
printf("waiting to free\n");
}
callbackRequest (pdpvt->call);
/* Advance the que */
pport->que = que->next;
/* free the one we just finished */
fprintf(stderr, "Freeing %s\n",prec->name);
free(que->send);
free(que);
epicsMutexUnloc k(*lock);

And from the requesting threads:
while( epicsMutexLockO K != epicsMutexLock( *lock)){
printf("wiat for lock:ai\n");
epicsThreadSlee p(0);
}
if(pport->que){
que = pport->que;
while(que->next){
que = que->next;
}
que->next = request;
DEBUG(6,("Addin g to NON empty Que\n"));
}
else{
DEBUG(6,("Addin g to empty Que\n"));
pport->que = request;
if(pport->que != request){
fprintf(stderr, "Did not add to Que!!");
}
}
epicsMutexUnloc k(*lock);
Any help, pointers, or pointing out of stupid mistakes ( other than my
lousy spelling ) Would be very much welcome.

--Bill

May 19 '06 #1
1 1917
Bill wrote:

I've got my self a bug that I am out of ideas on how to fix...
A section of my program launches a thread to handle a FIFO work
buffer,


C has no provision for threads. This is system specific, and thus
OT on c.l.c. Try a newsgroup with 'thread' in its name, or a group
specific to your system.

--
"The most amazing achievement of the computer software industry
is its continuing cancellation of the steady and staggering
gains made by the computer hardware industry..." - Petroski
May 19 '06 #2

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

Similar topics

5
2573
by: nicolas_riesch | last post by:
Does someone know if the module pytz (http://sourceforge.net/projects/pytz/) is thread-safe ? I have not seen it explicitely stated, and just wanted to be sure, as I want to use it. That's because in the file pytz/tzinfo.py, I see global variables _timedelta_cache, _datetime_cache, _ttinfo_cache, which are dictionnaries and are used as cache. I always thought that you must protect shared data with locks when multithreading, but I don't...
22
4097
by: Morpheus | last post by:
Hi, I have been coding in Windows for many years so have a mindset to it, so forgive any stupid questions. Is it possible to create a multithread application in C++ that is portable (OS/compiler)? In my Windows applications, I use synchronization objects like, mutex, semaphores etc. Is there anything similar in the Standard ANSI C++ or would I be best off doing this myself, possibly creating a new class to handle any critical...
15
2785
by: Laser Lu | last post by:
I was often noted by Thread Safety declarations when I was reading .NET Framework Class Library documents in MSDN. The declaration is usually described as 'Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.' So, does this mean All the static/shared methods written in .NET compatible programming language, such as C#, VB.NET, are guaranteed to be...
13
12116
by: Laser Lu | last post by:
I was often noted by Thread Safety declarations when I was reading .NET Framework Class Library documents in MSDN. The declaration is usually described as 'Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.' So, does this mean All the static/shared methods written in .NET compatible programming language, such as C#, VB.NET, are guaranteed to be...
13
3610
by: arun.darra | last post by:
Are the following thread safe: 1. Assuming Object is any simple object Object* fn() { Object *p = new Object(); return p; } 2. is return by value thread safe?
0
9425
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10225
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10053
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10001
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.