On Wed, 9 Oct 2002, David Brownell wrote:
>
> Or better yet, use the <linux/completion.h> primitives and
> call wait_for_completion() ... if your event model allows.
I think it would allow, but the problem seems to be that the disconnect
routine cannot wait indefinitely for a wake up call from the release
function. Unfortunately, as Oliver pointed out, a user opening the device
and not releasing it for ages is valid.
I've tried to solve it in the following manner:
release {
get disconnect mutex
decrement users
if ( !users and camera is disconnected ) {
free memory
return
}
release disconnect mutex
}
In the event that users is zero and the camera is gone, we free the memory
and don't release the mutex. 1) The mutex has been kfreed, and 2) We know
that disconnect has already completed because _we_ hold the lock (see
below), so there is no need to relase the mutex.
disconnect {
get disconnect mutex
mark camera as unplugged
...
unregister device
if ( !users ) {
free memory
} else {
release disconnect mutex
}
}
Again if the memory is freed, we don't touch the mutex.
How does this look?
Thanks,
John
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel