I am not sure if I am just missing something in the documentation but is there some way to specify a count on a Semaphore like a Posix Semaphore or Windows Semaphore. From what I can see it looks like it only support a count of 1. I have seen some implementations using PThreads but I was hoping to create a native implementation so I can control the tasks with pause and restart which is missing from PThreads. I'm trying to implement a ThreadPool like functionality.
Thanks
Doug
Semaphore
- tonyw
- AmigaOS Core Developer
- Posts: 1479
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: Semaphore
If you look up the "struct SignalSemaphore" in SDK:include/include_h/exec/semaphores.h, you will see the two 16-bit counts, one for the task that currently "owns" the semaphore and the other for the queue of other tasks waiting for it.
The nesting/counting action is described in SDK:Documentation/AutoDocs/exec.doc/ObtainSemaphore.
The nesting/counting action is described in SDK:Documentation/AutoDocs/exec.doc/ObtainSemaphore.
cheers
tony
tony
Re: Semaphore
There is also documentation on Semaphores here:
http://wiki.amigaos.net/wiki/Exec_Semaphores
http://wiki.amigaos.net/wiki/Exec_Semaphores
ExecSG Team Lead
Re: Semaphore
Our semaphores more or less match what other system call a "mutex", i.e. something that can be obtained once only. In contrast to a mutex the semaphore of other systems can be obtained up to n times in parallel, but the n+1 accessor will be blocked until one of the first n releases the semaphore again. This is something that the struct SignalSemaphore of AmigaOS cannot provide (yet). At least this is how I understand the situation.
Re: Semaphore
@All - I appreciate the replies.
@tboeckel - That was my understanding from documentation but thought I might have missed something.
I will look into rolling my own. I know it can be done from what I have read with condition variable and a mutex as I have seen some implementations with pthreads. I was hoping to keep it native.
Regards
Doug
@tboeckel - That was my understanding from documentation but thought I might have missed something.
I will look into rolling my own. I know it can be done from what I have read with condition variable and a mutex as I have seen some implementations with pthreads. I was hoping to keep it native.
Regards
Doug