以下是关于 xSemaphoreTake() 函数的 FreeRTOS api-reference http://www.freertos.org/a00122.html的摘录:
// 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 );
}