[prev in list] [next in list] [prev in thread] [next in thread] 

List:       uclinux-dev
Subject:    RE: [uClinux-dev] problem with restart of pthread
From:       "Falk Brettschneider" <falk.brettschneider () gmx ! de>
Date:       2005-11-18 14:33:40
Message-ID: 32161.1132324420 () www47 ! gmx ! net
[Download RAW message or body]

I'm analyzing further and have found out it seems to be a problem with
pthread_setcanceltype().
The exec-function of thread2 calls
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldType) as one of the
first code lines which allows thread1 to cancel thread2 with immediate
response. The exit handler calls pthread_setcanceltype(oldType, 0) which
usually restores PTHREAD_CANCEL_DEFERRED.

It looks to me the thread's exec-function internally uses
PTHREAD_CANCEL_ASYNCHRONOUS only during the first execution, but it behaves
wrong like a type==PTHREAD_CANCEL_DEFERRED for all further runs, although
pthread_setcanceltype() always exits normally.

Interesting is: Commenting out the call of pthread_setcanceltype(oldType, 0)
in the exit-handler has the effect that thread2 doesn't exit on cancellation
points anymore. Strange...
Hmm...I cannot surrender using pthread_setcanceltype to change to
PTHREAD_CANCEL_ASYNCHRONOUS since I need an immediate abort of the thread
and there are no much cancellation points in the code.

Cheers
F@lk

> --- Ursprüngliche Nachricht ---
> Von: "Falk Brettschneider" <falk.brettschneider@gmx.de>
> An: uClinux development list <uclinux-dev@uclinux.org>
> Betreff: RE: [uClinux-dev] problem with restart of pthread
> Datum: Fri, 18 Nov 2005 12:38:19 +0100 (MET)
> 
> Hi Lars + *,
> meanwhile I found out the described 800ms for all executions of thread2
> after the first restart are just because I use a mutex (for writing to
> log-buffer protected with pthread_mutex_lock()/pthread_mutex_unlock())
> there
> after a while. That seems to trigger the scheduller somehow. If I comment
> out the mutex usage, it doesn't switch back to thread1 anymore.
> Cheers
> F@lk
> 
> -- 
> Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
> Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner
> _______________________________________________
> uClinux-dev mailing list
> uClinux-dev@uclinux.org
> http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
> This message was resent by uclinux-dev@uclinux.org
> 

-- 
Telefonieren Sie schon oder sparen Sie noch?
NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic