* RE: [LCP]FW: pthread_mutex_lock call hangs
@ 2003-03-12 7:34 Ajay Bansal
0 siblings, 0 replies; only message in thread
From: Ajay Bansal @ 2003-03-12 7:34 UTC (permalink / raw)
To: linuxcprogramming, gcc-help, redhat-devel-list
[-- Attachment #1.1: Type: text/plain, Size: 2189 bytes --]
Hi All
I have been able to solve the problem. But the root cause is still not
clear. Following is the scenario in the code.
I have a class CriticalSection which is being used in the class for
locking.
Following is the class
typedef struct _critsection {
pthread_t Owner;
int LockDepth;
pthread_mutex_t Lock;
} CRITICAL_SECTION;
typedef class CriticalSection {
public:
CriticalSection() { CriticalSectionLock.Owner = 0;
CriticalSectionLock.Lock = GenericMutexInitializer; }
int Lock() { return EnterCriticalSection(&CriticalSectionLock); }
//for locking the mutex
void Unlock() { LeaveCriticalSection(&CriticalSectionLock); } //for
unlocking the mutex
private:
CRITICAL_SECTION CriticalSectionLock;
}CCriticalSection;
My code uses the above class as
class myClass {
private
.
.
.
CCriticalSection myLock;
public:
void Lock(){myLock.Lock();}
};
main()
{
.
.
myClass *myObj = new myObj();
myObj.Lock()
.
.
.
}
Now in debug mode, initializer of "CriticalSection" is not being called.
& then locking fails. As soon as I change the name of class
"CriticalSection" to some other name.. say "ACriticalSection". code
works fine.
what can this mean?? & why this behaviour only in the debug mode?????
-----Original Message-----
From: Vincent Penquerc'h [mailto:Vincent.Penquerch@artworks.co.uk]
Sent: Friday, March 07, 2003 11:03 PM
To: 'linuxcprogramming@lists.linux.org.au'
Subject: RE: [LCP]FW: pthread_mutex_lock call hangs
> > Only difference between two build is of "-g" flag. There is
And about the link ? Are different libs being linked against ?
Sorry to state the obvious.
Only think I can think of is timing issues. Debug info in the exe
could *maybe* cause more disk load at startup, which could influence
the thread timing. Just a shot in the dark, really.
To make sure it's not something else that -g, strip your program
compiled with -g, and test it. Stripped program should be the same
as the release one.
(Sorry about the HTML, it's converted after my mailer sends plain
text).
--
Vincent Penquerc'h
[-- Attachment #1.2: Type: text/html, Size: 7350 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-03-12 6:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-12 7:34 [LCP]FW: pthread_mutex_lock call hangs Ajay Bansal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).