Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Aug 2019 10:10:02 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Daniel Eischen <deischen@freebsd.org>
Cc:        Erich Dollansky <freebsd.ed.lists@sumeritec.com>, freebsd-questions@freebsd.org, freebsd-threads@freebsd.org
Subject:   Re: mutex held in a thread which is cancelled stays busy
Message-ID:  <20190807071002.GF2731@kib.kiev.ua>
In-Reply-To: <1FC05CEB-982F-484F-9E41-5A74FF564494@freebsd.org>
References:  <20190806165429.14bc4052.freebsd.ed.lists@sumeritec.com> <1FC05CEB-982F-484F-9E41-5A74FF564494@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Aug 06, 2019 at 08:58:30PM -0400, Daniel Eischen wrote:
> 
> > On Aug 6, 2019, at 4:54 AM, Erich Dollansky <freebsd.ed.lists@sumeritec.com> wrote:
> > 
> > Hi,
> > 
> > for testing purpose, I did the following.
> > 
> > Start a thread, initialise a mutex in a global variable, lock the mutex
> > and wait in that thread.
> > 
> > Wait in the main program until above's thread waits and cancel it.
> > 
> > Clean up behind the cancelled thread but leave intentional the mutex
> > locked.
> > 
> > I would have expected now to get an error like 'EOWNERDEAD' doing
> > operations with that mutex. But I get 'EBUSY' as the error.
> 
> Are you initializing the mutex as a robust mutex, via pthread_mutexattr_setrobust()?  Are you using _lock() or _trylock()?
> 
Robust mutexes only have special properties on the process termination.
They behave same as the normal mutexes if the owning thread is terminated.

> For _trylock(), you only get EOWNERDEAD for robust mutexes.  It seems that you should get EOWNERDEAD for _lock() in this case, so if that's what you're doing, it sounds like it might be a bug.
> 
> --
> DE
> _______________________________________________
> freebsd-threads@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-threads
> To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org"



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