Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Sep 2015 11:19:47 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Erich Dollansky <erichsfreebsdlist@alogt.com>
Cc:        freebsd-threads@freebsd.org, FreeBSD stable <freebsd-stable@freebsd.org>
Subject:   Re: pthread_cancel / sleep change in behaviour
Message-ID:  <20150903081947.GB2072@kib.kiev.ua>
In-Reply-To: <20150903080047.16be939e@X220.alogt.com>
References:  <20150903080047.16be939e@X220.alogt.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Sep 03, 2015 at 08:00:47AM +0800, Erich Dollansky wrote:
> Hi,
> 
> I noticed a change in behaviour when calling pthread_cancel for a
> thread which is sleeping using i.e. sleep ().
> 
> How I understand pthread_cancel, it should cancel the thread and call
> the clean up handler soon after its return. Important is that the
> cancelled thread waited on a cancellation point.
> 
> When I started testing our application under error conditions, I found
> problems I could not explain. As the application's target is a
> Raspberry, some tests have been done on a 10.1 on the Raspberry and
> some on a amd64 machine running 10.2 STABLE. The behaviour on the
> Raspberry was as expected but not on the amd64.
> 
> The situation is now that there are always pairs of threads. One thread
> does the work, the other thread just does a sleep() and cancels the
> worker thread at the end. But, when the worker thread finishes its work
> normally, it cancels the sleeping thread and then returns.
> 
> After some time of testing I found out that pthread_cancel calls the
> clean up handler of the sleeping thread only after sleep()'s return
> when running on 10.2 STABLE on amd64 but calls the clean up handler
> soon after cancellation on 10.1 on the Raspberry.
> 
> Is this change of behaviour a feature or a bug?

Provide a minimal example demonstrating the issue.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150903081947.GB2072>