Hello, So this is my latest code:
void inline __fastcall lockCriticalSection(TCriticalSection *criticalSection) { for(int i = 0; i < 5000; ++i) { if(criticalSection->TryEnter()) return; ::Sleep(1); } throw Exception("BUG FOUND, CHECK CALL STACK!"); //criticalSection->Acquire(); }; Is it OK? Regards, SZ On 4/28/07, Arno Garrels <[EMAIL PROTECTED]> wrote: > Fastream Technologies wrote: > > For example, perhaps we can implement a single global mutex for the > > lock... function. > > No good idea. That would change a lot. > > > This would slow down the execution for sure but > > would it create the exception? > > You have to raise the exception if the wait returns WAIT_TIMEOUT. > > > Can you provide some source code > > snippet for this please? > > Please search the internet there should be tons of snippets > around, or ask your question in newsgroup: > borland.public.delphi.nativeapi.win32. > > -- > Arno Garrels [TeamICS] > http://www.overbyte.be/eng/overbyte/teamics.html > > > > > Best Regards, > > > > SZ > > > > On 4/28/07, Fastream Technologies <[EMAIL PROTECTED]> wrote: > >> Arno, > >> > >> I have THOUSANDS of critical sections passed to this function as > >> parameter! Isn't there a simpler way to implement?? > >> > >> Regards, > >> > >> SZ > >> > >> On 4/28/07, Arno Garrels <[EMAIL PROTECTED]> wrote: > >>> Fastream Technologies wrote: > >>>> This sounds reasonable. Can you give an example? Since all my cs > >>>> are of TCriticalSection type, can I do it in this function: > >>> > >>> I thought of using mutexes. That's not very difficult to change. > >>> Have an array of mutex handles, then pass the index to your > >>> function. Search for CreateMutex etc. in the SDK. When the wait > >>> returned WAIT_TIMEOUT and you raise an exception MadExcept will > >>> report the callstacks of each thread. > >>> I don't have any idea how one can raise an exception in a thread > >>> or get to thread's callstack when it hangs around in > >>> CriticalSection->Acquire. > >>> > >>> -- > >>> Arno Garrels [TeamICS] > >>> http://www.overbyte.be/eng/overbyte/teamics.html > >>> > >>>> > >>>> void __fastcall lockCriticalSection(TCriticalSection *CS) > >>>> { > >>>> // currently it is: > >>>> CS->Acquire(); > >>>> > >>>> // what should it be? > >>>> } > >>>> > >>>> Best Regards, > >>>> > >>>> SZ > >>>> > >>>> On 4/28/07, Arno Garrels <[EMAIL PROTECTED]> wrote: > >>>>> Fastream Technologies wrote: > >>>>>> Hello, > >>>>>> > >>>>>> I have a very difficult bug: the program includes lots of > >>>>>> critical sections and it suddenly stops responding! > >>>>> > >>>>> Sounds like deadlock. > >>>>> > >>>>>> I have a wrapper global > >>>>>> function called lockCriticalSection(TCriticalSection *cs) which > >>>>>> calls acquire. I want to log inside this but need to record the > >>>>>> call stack so that I can see which call is the lastest. Any idea? > >>>>> > >>>>> AFAIK Jedi gives you the callstack only upon an exception. > >>>>> My idea is to use a different synchronization method with a > >>>>> timeout parameter, when the wait timed out you can raise an > >>>>> exception. > >>>>> > >>>>> Would that help? > >>>>> > >>>>> -- > >>>>> Arno Garrels [TeamICS] > >>>>> http://www.overbyte.be/eng/overbyte/teamics.html > >>>>> > >>>>>> > >>>>>> Best Regards, > >>>>>> > >>>>>> SZ > >>>>> -- > >>>>> To unsubscribe or change your settings for TWSocket mailing list > >>>>> please goto http://www.elists.org/mailman/listinfo/twsocket > >>>>> Visit our website at http://www.overbyte.be > >>>>> > >>>> > >>>> > >>>> -- > >>>> CSA, Fastream Technologies > >>>> Software IQ: Innovation & Quality > >>>> www.fastream.com | Email: [EMAIL PROTECTED] | Tel: +90-312-223- > >>>> 2830 Join IQWF Server Yahoo group at > >>>> http://groups.yahoo.com/group/IQWFServer Join IQ Reverse Proxy > >>>> Yahoo group at http://groups.yahoo.com/group/IQReverseProxy > >>> -- > >>> To unsubscribe or change your settings for TWSocket mailing list > >>> please goto http://www.elists.org/mailman/listinfo/twsocket > >>> Visit our website at http://www.overbyte.be > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be > -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be