Question 1
Consider the following FreeRTOS code snippet:
#include "FreeRTOS.h"#include "task.h"#include "queue.h"
QueueHandle_t xQueue;
void SenderTask(void *pvParameters) { int data = 100; while (1) { if (xQueueSend(xQueue, &data, pdMS_TO_TICKS(1000)) == pdPASS) { printf("Data sent: %d\n", data); } vTaskDelay(pdMS_TO_TICKS(500)); }}
void ReceiverTask(void *pvParameters) { int receivedData; while (1) { if (xQueueReceive(xQueue, &receivedData, pdMS_TO_TICKS(2000)) == pdTRUE) { printf("Data received: %d\n", receivedData); } }}
int main() { xQueue = xQueueCreate(5, sizeof(int));
xTaskCreate(SenderTask, "Sender", 1000, NULL, 1, NULL); xTaskCreate(ReceiverTask, "Receiver", 1000, NULL, 1, NULL);
vTaskStartScheduler(); while (1);}What will happen if the receiver task is delayed for more than 3 seconds?
The sender task will be blocked permanently
The queue will eventually be full, and the sender task will be blocked until space is available
The queue will clear automatically, allowing the sender to continue
The system will crash due to queue overflow
