src/ppe/pk/kernel/pk_semaphore_core.c
/// Release all threads blocked on a semaphore
///
/// \param semaphore A pointer to a semaphore
///
/// This API is provided to allow an PK semaphore to be used as a thread
/// barrier. pk_semaphore_release_all() simultaneously unblocks all threads
/// (if any) currently pending on a semaphore. A semaphore to be used as a
/// thread barrier will typically be initialized with
/// pk_semaphore_create(\a sem, 0, 0), and sxx_semaphore_post() would never be
/// called on the \a sem.
///
/// This API never modifies the \a count field of the semaphore; If any
/// threads are blocked on a semaphore the semaphore count is 0 by definition.
///
/// Return values other than PK_OK (0) are errors; see \ref pk_errors
///
/// \retval 0 Successful completion
///
/// \retval -PK_INVALID_SEMAPHORE_AT_RELEASE The \a semaphore is a null (0) 
/// pointer.
Release all threads blocked on a semaphore
\param semaphore A pointer to a semaphore

This API is provided to allow an PK semaphore to be used as a thread
barrier. pk_semaphore_release_all() simultaneously unblocks all threads
(if any) currently pending on a semaphore. A semaphore to be used as a
thread barrier will typically be initialized with
pk_semaphore_create(\a sem, 0, 0), and sxx_semaphore_post() would never be
called on the \a sem.

This API never modifies the \a count field of the semaphore; If any
threads are blocked on a semaphore the semaphore count is 0 by definition.

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

\retval 0 Successful completion

\retval -PK_INVALID_SEMAPHORE_AT_RELEASE The \a semaphore is a null (0)
pointer.
Release all threads blocked on a semaphore \ param semaphore A pointer to a semaphore This API is provided to allow an PK semaphore to be used as a thread barrier . pk_semaphore_release_all () simultaneously unblocks all threads ( if any ) currently pending on a semaphore . A semaphore to be used as a thread barrier will typically be initialized with pk_semaphore_create ( \ a sem 0 0 ) and sxx_semaphore_post () would never be called on the \ a sem . This API never modifies the \ a count field of the semaphore ; If any threads are blocked on a semaphore the semaphore count is 0 by definition . Return values other than PK_OK ( 0 ) are errors ; see \ ref pk_errors \ retval 0 Successful completion \ retval - PK_INVALID_SEMAPHORE_AT_RELEASE The \ a semaphore is a null ( 0 ) pointer .
int
pk_semaphore_release_all(PkSemaphore* semaphore)
{
    PkMachineContext ctx;
    if (PK_ERROR_CHECK_API) {
        PK_ERROR_IF(semaphore == 0, PK_INVALID_SEMAPHORE_AT_RELEASE);
    }
    pk_critical_section_enter(&ctx);
    __pk_thread_queue_union(&__pk_run_queue, &(semaphore->pending_threads));
    __pk_thread_queue_clear(&(semaphore->pending_threads));
    __pk_schedule();
    pk_critical_section_exit(&ctx);
    return PK_OK;
}
int pk_semaphore_release_all ( PkSemaphore * semaphore ) { PkMachineContext ctx ; if ( PK_ERROR_CHECK_API ) { PK_ERROR_IF ( semaphore == 0 , PK_INVALID_SEMAPHORE_AT_RELEASE ) ; } pk_critical_section_enter ( & ctx ) ; __pk_thread_queue_union ( & __pk_run_queue , & ( semaphore -> pending_threads ) ) ; __pk_thread_queue_clear ( & ( semaphore -> pending_threads ) ) ; __pk_schedule ( ) ; pk_critical_section_exit ( & ctx ) ; return PK_OK ; }
Release all threads blocked on a semaphore
\param semaphore A pointer to a semaphore
Release all threads blocked on a semaphore \ param semaphore A pointer to a semaphore