From uclinux-dev Fri Nov 18 14:33:40 2005 From: "Falk Brettschneider" Date: Fri, 18 Nov 2005 14:33:40 +0000 To: uclinux-dev Subject: RE: [uClinux-dev] problem with restart of pthread Message-Id: <32161.1132324420 () www47 ! gmx ! net> X-MARC-Message: https://marc.info/?l=uclinux-dev&m=113232446328039 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" > An: uClinux development list > 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