When working with SBCL
semaphores (sb-thread
package) I can easily check the current semaphore count, as demonstrated by the snippet below:
CL-USER> (defvar *semaphore* (sb-thread:make-semaphore))
*SEMAPHORE*
CL-USER> (sb-thread::semaphore-count *semaphore*)
0
CL-USER> (sb-thread::signal-semaphore *semaphore*)
NIL
CL-USER> (sb-thread::semaphore-count *semaphore*)
1
I've been trying to do the same in Clozure CL
(using the ccl
package) but was unable to. Here's an example:
CL-USER> (defvar *semaphore* (ccl:make-semaphore))
*SEMAPHORE*
CL-USER> (ccl::semaphore-value *semaphore*)
#<A Foreign Pointer [gcable] #x7F6B240050B0>
When I inspect the Foreign Pointer
, this is what I see:
#<MACPTR #x30200080B31D>
--------------------
@0=#<A Foreign Pointer [gcable] #x7F6B240050B0>
Underlying UVECTOR
I was unable to find any way to access the internal counter, nor to find any substantial hint to that effect. I've been thinking about perhaps using the foreign function interface and making use of the sem_getvalue
system call, but do not yet know how to go about it. Do you have any suggestions or insights as to how to access this counter? Any help greatly appreciated.