Re: Semaphore questions?
Re: Semaphore questions?
- Subject: Re: Semaphore questions?
- From: Terry Lambert <email@hidden>
- Date: Wed, 6 Oct 2010 12:04:57 -0700
On Oct 6, 2010, at 4:33 AM, sheetal phirke wrote:
> Hello All,
>
> I am newbie in mac. i have query about following things with semaphore
>
> i am trying to use mach semaphore in IOKit. i have following questions :-
>
> 1: Do mach semaphore provide functions to get semaphore count? if not the why?
No. You are supposed to know the value you set with semaphore_create(), and count it down. See:
osfmk/kern/sync_sema.c
<http://books.google.com/books?id=K8vUkpOXhN4C&pg=PA1219&lpg=PA1219&dq=amit+singh+mach+semaphores&source=bl&ots=OJplS-RvVD&sig=9J_x18n-zbejT9aAZq3oOROLEj8&hl=en&ei=W8OsTMSjBpO8sQOuhNTwAw&sa=X&oi=book_result&ct=result&resnum=1&ved=0CBIQ6AEwAA#v=onepage&q&f=false>
> 2: For mach semaphore one function available which is semaphore_signal_thread(), but for mac os x 10.6.2 i didn't found in semaphore.h?
It's kernel private, which means is SPI for use in the OS implementation itself. It's not in the exported symbols list, and it's not available. In general, you don't know which thread(s) are waiting on the semaphore, so you don't know the thread parameter to pass to this function. It's basically an implementation detail for pthread condition variables in Libc, and should not be used by your code.
> 3: I have try to go with POSIX semaphore, but it is not possible to implement in kernel.
Correct. You can not use semaphores to communicate between the kernel and user space. Instead, you should use object wrappers such as IOCommandQueue or IOService.
-- Terry
>
> Thanks,
> Sheetal.
_______________________________________________
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