QP/C  8.0.0
Real-Time Embedded Framework
Loading...
Searching...
No Matches
QXSemaphore Class Reference

Counting Semaphore of the QXK preemptive kernel. More...

Detailed Description

Counting Semaphore of the QXK preemptive kernel.

Details
QXSemaphore is a blocking mechanism intended primarily for signaling extended threads. The semaphore is initialized with the maximum count (see QXSemaphore_init()), which allows you to create a binary semaphore (when the maximum count is 1) and counting semaphore when the maximum count is > 1.
Usage
The following example illustrates how to instantiate and use the semaphore in your application.
QXSemaphore BTN_sema; // semaphore to signal a button press//
int main() {
. . .
// initialize the BTN_sema semaphore as binary, signaling semaphore//
QXSemaphore_init(&BTN_sema, // pointer to semaphore to initialize//
0U, // initial semaphore count (signaling semaphore)//
1U); // maximum semaphore count (binary semaphore)//
. . .
}
void main_threadXYZ(QXThread * const me) {
while (1) {
. . .
QXSemaphore_wait(&BTN_sema, // <--- pointer to semaphore to wait on//
QXTHREAD_NO_TIMEOUT); // timeout for waiting//
. . .
}
}
void GPIO_Handler(void) {
. . .
QXSemaphore_signal(&BTN_sema); // <--- pointer to semaphore to signal//
. . .
}
Counting Semaphore of the QXK preemptive kernel.
eXtended (blocking) thread of the QXK preemptive kernel

The documentation for this class was generated from the following file: