这是 FreeRTOS api 引用的摘录 http://www.freertos.org/a00122.html关于 xSemaphoreTake() 函数:
// See if we can obtain the semaphore. If the semaphore is not available
// wait 10 ticks to see if it becomes free.
if( xSemaphoreTake( xSemaphore, ( portTickType ) 10 ) == pdTRUE )
{
// We were able to obtain the semaphore and can now access the
// shared resource.
我的问题是:我这里已经有了信号量还是必须调用
xSemaphoreTake( xSemaphore, (portTickType) 10 )
明确如:
// We have finished accessing the shared resource. Release the
// semaphore.
xSemaphoreGive( xSemaphore );
}
最佳答案
在您链接到的示例中,在 if (...) 正文中采用了信号量。如果您从该示例复制粘贴,则由您来确保您的程序中同时具有 xSemaphoreTake 和 xSemaphoreGive。
关于c - FreeRTOS 信号量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14165218/