• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
current_task() in start() , stop(), thread differs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: current_task() in start() , stop(), thread differs
      • From: Brian Bergstrand <email@hidden>
  • Prev by Date: Re: Question on Filter scheme driver example
  • Next by Date: Re: current_task() in start() , stop(), thread differs
  • Previous by thread: Re: non blocking memory allocation api
  • Next by thread: Re: current_task() in start() , stop(), thread differs
  • Index(es):
    • Date
    • Thread