I am working with FreeRTOS and I am using xQueueReceive() within a task that I created with xTaskCreate()
. The task does only handle received network packets. Here's the task's implementation:
while(1) {
if(sys_link_recv_queue != NULL) {
mb32_packet_t packet;
if(xQueueReceive(sys_link_recv_queue, &packet, portMAX_DELAY)==pdPASS) {
// process packet ...
}
}
}
When using portMAX_DELAY
, the queue waits indefinitely until a queue item gets available. My question is now whether I loose valuable CPU time during this wait state or if this is the recommended way of doing this. If it's not the most economical way of doing this, what's the alternative?
portMAX_DELAY
probably is a constant indicating a maximum time before the I/O system determines there is a time-out. It then resumes the task, which now returns an indication "nothing received within the time-out time". – Paul OgilvieportMAX_DELAY
depends on the port. It may mean indefinitelly or not. You need to check your port documentation / source code. Some ports ignore additional checks if this delay may mean many months. – 0___________