src/ppe/pk/kernel/pk_semaphore_core.c
/// Get information about a semaphore.
///
/// \param semaphore A pointer to the PkSemaphore to query
///
/// \param count The value returned through this pointer is the current count
/// of the semaphore.  The caller can set this parameter to the null pointer
/// (0) if this information is not required.
///
/// \param pending The value returned through this pointer is the current
/// number of threads pending on the semaphore. The caller can set this
/// parameter to the null pointer (0) if this information is not required.
///
/// The information returned by this API can only be guaranteed consistent if
/// the API is called from a critical section.
///
/// Return values other than PK_OK (0) are errors; see \ref pk_errors
///
/// \retval 0 Successful completion
///
/// \retval -PK_INVALID_SEMAPHORE_AT_INFO The \a semaphore is a null (0) 
/// pointer.
Get information about a semaphore.
\param semaphore A pointer to the PkSemaphore to query

\param count The value returned through this pointer is the current count
of the semaphore.  The caller can set this parameter to the null pointer
(0) if this information is not required.

\param pending The value returned through this pointer is the current
number of threads pending on the semaphore. The caller can set this
parameter to the null pointer (0) if this information is not required.

The information returned by this API can only be guaranteed consistent if
the API is called from a critical section.

Return values other than PK_OK (0) are errors; see \ref pk_errors

\retval 0 Successful completion

\retval -PK_INVALID_SEMAPHORE_AT_INFO The \a semaphore is a null (0)
pointer.
Get information about a semaphore . \ param semaphore A pointer to the PkSemaphore to query \ param count The value returned through this pointer is the current count of the semaphore . The caller can set this parameter to the null pointer ( 0 ) if this information is not required . \ param pending The value returned through this pointer is the current number of threads pending on the semaphore . The caller can set this parameter to the null pointer ( 0 ) if this information is not required . The information returned by this API can only be guaranteed consistent if the API is called from a critical section . Return values other than PK_OK ( 0 ) are errors ; see \ ref pk_errors \ retval 0 Successful completion \ retval - PK_INVALID_SEMAPHORE_AT_INFO The \ a semaphore is a null ( 0 ) pointer .
int
pk_semaphore_info_get(PkSemaphore*      semaphore,
                       PkSemaphoreCount* count,
                       int*               pending)
{
    if (PK_ERROR_CHECK_API) {
        PK_ERROR_IF(semaphore == 0, PK_INVALID_SEMAPHORE_AT_INFO);
    }
    if (count) {
        *count = semaphore->count;
    }
    if (pending) {
        *pending = __pk_thread_queue_count(&(semaphore->pending_threads));
    }
    return PK_OK;
}
int pk_semaphore_info_get ( PkSemaphore * semaphore , PkSemaphoreCount * count , int * pending ) { if ( PK_ERROR_CHECK_API ) { PK_ERROR_IF ( semaphore == 0 , PK_INVALID_SEMAPHORE_AT_INFO ) ; } if ( count ) { * count = semaphore -> count ; } if ( pending ) { * pending = __pk_thread_queue_count ( & ( semaphore -> pending_threads ) ) ; } return PK_OK ; }
Get information about a semaphore.
Get information about a semaphore .