current_task() in start() , stop(), thread differs
current_task() in start() , stop(), thread differs
- Subject: current_task() in start() , stop(), thread differs
- From: Parav Pandit <email@hidden>
- Date: Fri, 28 Jan 2005 17:44:12 +0000 (GMT)
Hi,
Please grant me to ask this silly question.
I am creating one thread using IOCreateThread().
I want to do syncronization between this thread and my
interrupt handler, which is in the workloop thread.
Currently I create one semaphore using
semaphore_create(current_task()) in the start().
My CreateThread sleeps on this semaphore,
when isr completes it's job, it does
semaphore_signal().
And than I do semaphore_destroy(current_task(), ..)
in the stop().
This has memory leak, I believe.
I did IOLog("current_task = %p\n", current_task());
at (1) start()
(2) Inside my created kernel thread
(3) stop().
At all the 3 places current_task() is different.
So when i do semaphore_destory() from the stop(), it
won't get destoryed.
start() stop() code is initiated by user command
kextload/unload but still executed from the kernel
task, isn't it?
Why all the 3 places shows different?
Does it mean that I have to create those semaphores
inside my thread and when I come out of this thread
using IOExitThread(), before that I should destroy
them.
like
IOCreateThread (MyThread,..)
MyThread()
{
semaphore_create(current_task(), ...) ;
while(1)
{
semaphore_wait()
..........
.........
do the work()
}
signal received to comeout.
semaphore_destroy(current_task(), )
IOExitThread();
}
Or should I use some different mechanism?
Regards,
Parav Pandit
________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
_______________________________________________
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