Re: Thread join?
Re: Thread join?
- Subject: Re: Thread join?
- From: Duane Murphy <email@hidden>
- Date: Tue, 08 Dec 2009 22:39:27 -0800
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Well, I'm still trying to work out what is happening. I am working on
a disk driver (override). When the disk is removed (without being
ejected) things sometimes go awry. It seems that if the timing is
write and there is a thread that is making a request to the disk at
the time the disk is removed then after a timeout, it seems that
thread may be aborted.
I'm not entirely sure this is true, but I can end up with another
thread waiting on a mutex that the thread that is making the request
to the drive is supposed to release. But the thread is gone and the
mutex is still locked.
In summary, I'm using a mutex to indicate that a thread has completed.
One thread waits on that mutex until the IO thread exits. Under these
circumstances, the IO thread has gone, but the mutex is still locked.
Still doing debugging, but thread synchronization seems to be
something useful here.
I guess a related question would be how to tell that a thread is still
valid and active. That is a thread's state (given a thread reference
of course).
...Duane
On Dec 8, 2009, at 10:03 PM, Godfrey van der Linden wrote:
> IIRC there is no automatic way of doing this. In any case I had to
> roll my own with complicated locking and other weird hand off code.
> How is your thread terminating, are you returning from main or is it
> being aborted by another thread (if that is even possible)?
>
> I've just had a look at the IOWorkLoop termination code, it is
> pretty complicated to get right it seems to be necessary to call
> thread_deallocate() followed by thread_terminate(), this is all new
> to me so something has changed since I last worked in this area.
>
> Godfrey
>
> On 2009-12-09, at 12:42 PM, Duane Murphy wrote:
>
>> How would one do the equivalent of join() for a thread in the kernel?
>>
>> I think I have a situation where the underlying thread is exiting,
>> possibly aborting, so that my built in thread exit indicators do not
>> get called. This causes some threads to hang waiting for the thread
>> to
>> exit.
>>
>> Or maybe the right question is what is the appropriate way to wait on
>> a thread that may abort or already be aborted?
>>
>> ...Duane
>
...Duane
-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.10.0 (Build 500)
Charset: US-ASCII
wsBVAwUBSx9GJkrg9acQ4r2CAQjmRAgAzkArJ+FT4MRIsTspfYbkS+3Drr8T9fG7
wWyDppgKXD1vqTFbsbUIQkaArcL6g+eVwmzOnKO8bIta4pi6UMzQGclz6fNlNqiK
ZiDbHpbSqGwW9LE/BwjwdwqCifyYUGFmITFp6YZ9SsbFzRqHaMHtKbstJSb3U1so
3yxPlRDQpvKetppzKFXgLRCquC//jy06omp1cxOMh0oA/5Cs7YVRzYsjxfe/yv4u
4pD5qade7XIu0Y7j0CR+j+hXncq9ymuwkTF29t+yv0E0pWsQ/9gGIJKYoMOpNeaK
bOKkKFxTHtcF8PKv4FVWeosgaBgT4xvBP6HoNOSHc5wPHwOGvea5Tg==
=cUsb
-----END PGP SIGNATURE-----
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden