0% found this document useful (0 votes)
8 views

RTOS

The document consists of a series of questions and answers related to FreeRTOS API functions, task management, queues, semaphores, and interrupt handling. Each question tests knowledge on specific API functions, their parameters, and their behaviors in various scenarios. The correct answers are indicated for each question, providing a comprehensive overview of FreeRTOS concepts and usage.

Uploaded by

luciajin3107
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

RTOS

The document consists of a series of questions and answers related to FreeRTOS API functions, task management, queues, semaphores, and interrupt handling. Each question tests knowledge on specific API functions, their parameters, and their behaviors in various scenarios. The correct answers are indicated for each question, providing a comprehensive overview of FreeRTOS concepts and usage.

Uploaded by

luciajin3107
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Câu 1: It is safe to write to a queue from an interrupt service

routine, we can use which of the following API function?


A. xQueueReceiveFromISR()
B. xQueueReceive()
(Đúng) C. xQueueSendToBackFromISR()
D. xQueuePeekFromISR()
E. xQueueSendToBack()

Câu 2:

QueueHandle_t xQueueCreate( UBaseType_t uxQueueLength, UBaseType_t


uxItemSize

);

That is an API function used to create a queue. In which, what


is uxQueueLength?
A. A pointer to the memory into which the received data will
be copied.
B. None of the others
C. The size in bytes of each data item that can be stored in
the queue.
D. A pointer to the data to be copied into the queue.
(Đúng) E. The maximum number of items that the
queue being created can hold at any one time.

Câu 3:

Assume that a task is created as follow:


xTaskCreate(vTask2, "Task 2", 2000, NULL, 2, &xTask2Handle );
When this task is running, it can delete itself by calling to
vTaskDelete() as follow:
A. vTaskDelay(xTask2Handle);
(Đúng) B. vTaskDelete(xTask2Handle);
C. vTaskDelay(portMAX_DELAY);
(Đúng) D. vTaskDelete(NULL);
E. vTaskDelete(xTask1Handle);
Câu 4:

BaseType_t xTaskCreate(TaskFunction_t pvTaskCode,


const char * const pcName,
const configSTACK_DEPTH_TYPE uxStackDepth,
void *pvParameters,
UBaseType_t uxPriority,
TaskHandle_t *pxCreatedTask );
That is an API function used to create a task.
In which, what is uxPriority?
That is an API function used to create a task. In which, what is
uxPriority?
A. The Task Handler which is used to call the task for
various operations
B. A value that is passed as the parameter to the created
task.
C. The number of words to allocate for use as the task’s
stack.
D. A C function that never exit and are implemented as an
infinite loop
(Đúng) E. The priority at which the created task will
get.
F. A descriptive name for the task

Câu 5: The following lines come from FreeRTOSConfig.h:


#define configUSE_PREEMPTION 1
#define configMAX_PRIORITIES 15
#define configMINIMAL_STACK_SIZE 128
#define configMAX_TASK_NAME_LEN 16
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_TASK_NOTIFICATIONS 1
#define configUSE_QUEUE_SETS 0
#define configUSE_TIME_SLICING 0
#define configUSE_TICK_HOOK 0
Which of the followings are TRUE?
(Đúng) A. The tick hook function is NOT used.
B. Scheduling Algorithm is Co-operative.
C. The highest priority of a task is 15.
(Đúng) D. Scheduling Algorithm is Preemptive
Without Time Slicing.
(Đúng) E. The highest priority of a task is 14.
F. Scheduling Algorithm is Preemptive With Time Slicing.

Câu 6:
BaseType_t xTaskCreate( TaskFunction_t pvTaskCode,

const char * const pcName,


configSTACK_DEPTH_TYPE
uxStackDepth, void *
pvParameters,

UBaseType_t uxPriority,
TaskHandle_t *
pxCreatedTask );

That is an API function used to create a task. In which, what is


pxCreatedTask?
(Đúng) A. The Task Handler which is used to call the
task for various operations
B. The priority at which the created task will get.
C. A C function that never exit and are implemented as an
infinite loop

Câu 7:

What’s on the serial monitor?


(Đúng) A. Task is running with priority: 4
B. Task is running with priority: 2
C. Task is running with priority: 1
D. Task is running with priority: 3
E. None of the others

Câu 8: That is an API function used to create a queue. In


which, what is uxItemSize?
A. The maximum number of items that the queue being
created can hold at any one time.
B. A pointer to the data to be copied into the queue.
C. None of the others
D. A pointer to the memory into which the received data will
be copied.
(Đúng) E. The size in bytes of each data item that can
be stored in the queue.

Câu 9: Which of the following statements about semaphores


used in FreeRTOS are TRUE?
A. When the xSemaphoreCreateMutex() API function is
executed and if a non-NULL value is returned, it indicates that
the mutex has been created successfully. However, the
mutex is not available to be 'taken'.
(Đúng) B. Handles to all the various types of
FreeRTOS semaphores are stored in a variable of type
SemaphoreHandle_t.
C. When the xSemaphoreCreateBinary() API function is
executed and if a non-NULL value is returned, it indicates that
the semaphore has been created successfully and a binary
semaphore is available to be ‘taken’.
D. When the xSemaphoreCreateBinary() API function is
executed and if a NULL value is returned, it indicates that the
semaphore has been created successfully, and a binary
semaphore is available to be ‘taken’.
(Đúng) E. When the xSemaphoreCreateMutex() API
function is executed and if a non-NULL value is
returned, it indicates that the mutex has been created
successfully, and the mutex is available to be ‘taken’.

Câu 10:

That is an API function used to create a task. In which, what is


uxStackDepth?
A. A descriptive name for the task
B. The priority at which the created task will get.
(Đúng) C. The number of words to allocate for use as
the task's stack.
D. A C function that never exit and are implemented as an
infinite loop
E. The Task Handler which is used to call the task for
various operations
F. A value that is passed as the parameter to the created
task.

Câu 11:

Th
at is an API function used to send data to the back of a queue.
In which, what is xQueue?
A. A pointer to the memory into which the received data will
be copied.
B. A pointer to the data to be copied into the queue.
(Đúng) C. The handle of the queue to which the data
is being sent (written).
D. The size in bytes of each data item that can be stored in
the queue.
E. The maximum number of items that the queue being
created can hold at any one time.
Câu 12:
Which of the following API functions are used in this code?
(example014: Sending and receiving on a queue from within
an interrupt)
(Đúng) A. xQueueSendToBack()
(Đúng) B. vTaskDelayUntil()
C. xTaskGetPriority()
(Đúng) D. xTaskGetTickCount()
(Đúng) E. xQueueReceiveFromISR()
F. xQueueSendToFrontFromISR()
G. vTaskDelay()
(Đúng) H. xQueueSendToBackFromISR()

Câu 13: What is the API function used to query the number of
free spaces in a queue?
A. xQueueOverwrite(QueueHandle_t xQueue, const void *
pvItemToQueue)
B. None of the others
C. xQueuePeek(QueueHandle_t xQueue, void *pvBuffer,
TickType_t xTicksToWait)
(Đúng) D. uxQueueSpacesAvailable( QueueHandle_t
xQueue )
E. uxQueueMessagesWaiting( QueueHandle_t xQueue )
Câu 14:

What happens when another task or interrupt places data into


the queue (with multiple tasks blocked waiting for data)?
(Đúng) A. The task that is unblocked is always the
highest priority task that is waiting for data and has
been waiting the longest.
B. The task that is unblocked is always the highest priority
task that is waiting for data and has the longest 'block' time.
C. The task that is unblocked is always the task that has
been waiting the longest.
D. The task that is unblocked is always the highest priority
task that is waiting for data.
E. None of the others
Câu 15:

That is an API function used to create a task. In which, what is


pvTaskCode?
(Đúng) A. A C function that never exit and are
implemented as an infinite loop
B. The Task Handler which is used to call the task for
various operations
C. A descriptive name for the task
D. The priority at which the created task will get.
E. A value that is passed as the parameter to the created
task.
F. The number of words to allocate for use as the task's
stack.
Câu 16:

That is an API function used to receive (read) an item from a


queue. In which, what is pvBuffer?
A. The size in bytes of each data item that can be stored in
the queue.
B. The maximum amount of time the task should remain in
the Blocked state to wait for data to become available on the
queue, if the queue is already empty.
(Đúng) C. A pointer to the memory into which the
received data will be copied.
D. A pointer to the data to be copied into the queue.
E. The handle of the queue to which the data is being sent
(written).

Câu 17: What is “deferred interrupt processing” in FreeRTOS?


A. An interrupt service routine must record the cause of the
interrupt, clear the interrupt, and do other processing
necessitated by the interrupt.
B. An ISR is no longer used in FreeRTOS.
C. None of the others
(Đúng) D. The processing necessitated by the
interrupt is 'deferred' from the ISR to a task.
E. Some FreeRTOS ports allow interrupt nesting.
Câu 18: What is the API function used to query the number of
items currently in a queue?
A. xQueuePeek(QueueHandle_t xQueue, void *pvBuffer,
TickType_t xTicksToWait)
B. None of the others
(Đúng) C. uxQueueMessagesWaiting(QueueHandle_t
xQueue)
D. xQueueOverwrite(QueueHandle_t xQueue, const void
*pvItemToQueue)
E. uxQueueSpacesAvailable( QueueHandle_t xQueue )

Câu 19:

Look at the picture: What does the picture demonstrate?


A. Unbounded priority inversion: the medium priority task
(MP) could block the low and high priority tasks indefinitely.
(Đúng) B. Priority Inheritance: the low priority task
that holds the mutex 'inherits' the priority of the task
waiting for the mutex.
(Đúng) C. Priority inheritance minimizing the effect
of priority inversion.
D. Priority Inversion: the higher priority Task (HP) having to
wait for the lower priority Task (LP) to give up control of the
mutex.
Câu 20: Which of the followings can be used for mutual
exclusion in using resources?
(Đúng) A. Mutex
B. Queue Set
(Đúng) C. taskENTER_CRITICAL() ...
taskEXIT_CRITICAL()
(Đúng) D. vTaskSuspendAll() ... vTaskResumeAll()
E. Queue

Câu 21: Let review example015 about Rewriting vPrintString()


to use a semaphore. Which of the following statements are
TRUE about this code?
A. There are 2 Task functions defined in this code.
(Đúng) B. 1 mutex is created in this code.
(Đúng) C. There is only 1 Task function defined in
this code.
D. 2 mutexes are created in this code.
(Đúng) E. 2 task are created in this code and their
priorities are different.
Câu 22:

That is an API function used to create a task. In which, what is


pcName?
A. The Task Handler which is used to call the task for
various operations
(Đúng) B. A descriptive name for the task
C. A value that is passed as the parameter to the created
task.
D. The number of words to allocate for use as the task's
stack.
E. A C function that never exit and are implemented as an
infinite loop
F. The priority at which the created task will get.
Câu 23: That is the API function used to create a counting
semaphore. In which, what is uxInitialCount?
(Đúng) A. The initial count value of the semaphore
after it has been created.
B. The maximum value to which the semaphore will count.
C. When the semaphore is to be used to manage access to
a collection of resources, uxInitialCount should be set to zero
(0).
D. When the semaphore is to be used to count or latch
events, uxInitialCount should be set to equal uxMaxCount.
E. None of the others
Câu 24: What is the API function that specifies an absolute
time at which the task wishes to unblock?
A. None of the others
B. void vTaskDelayUntil( const TickType_t xTicksToDelay );
C. void vTaskDelay( const TickType_t xTicksToDelay );
D. void vTaskDelay(TickType_t *pxPreviousWakeTime, const
TickType_t xTimeIncrement );
(Đúng) E. void vTaskDelayUntil( TickType_t
*pxPreviousWakeTime, const TickType_t
xTimeIncrement );
Câu 25:
Look at the picture: What does the picture demonstrate?
A. Priority inheritance minimizing the effect of priority
inversion.
B. Priority Inheritance: the low priority task that holds the
mutex 'inherits' the priority of the task waiting for the mutex.
(Đúng) C. Unbounded priority inversion: the medium
priority task (MP) could block the low and high priority
tasks indefinitely.
(Đúng) D. Priority Inversion: the higher priority Task
(HP) having to wait for the lower priority Task (LP) to
give up control of the mutex.

Câu 26:

Which of the following statements are TRUE about this code?


(Sending and receiving on a queue from within an interrupt)
A. 2 semaphores are created in this code.
B. There are 2 ISRs in this code.
(Đúng) C. 1 task is created that sends 5 numbers to a
queue every 200 milliseconds. It generates a software
interrupt only after all five values have been sent.
(Đúng) D. 2 queues are created in this code.
(Đúng) E. 2 task are created in this code.
Câu 27: What are potential pitfalls of using mutexes for
mutual exclusion?
A. Priority Inheritance
(Đúng) B. Priority Inversion
(Đúng) C. Deadlock
D. A mutex can not be used in an ISR.
E. A mutex that is used for mutual exclusion must always be
returned.
Câu 28: That is an API function used to send data to the back
of a queue. In which, what is pvItemToQueue?
A. The size in bytes of each data item that can be stored in
the queue.
B. The handle of the queue to which the data is being sent
(written).
C. The maximum amount of time the task should remain in
the Blocked state to wait for space to become available on
the queue, should the queue already be full.
(Đúng) D. A pointer to the data to be copied into the
queue.
E. A pointer to the memory into which the received data will
be copied.
Câu 29:

That is an API function used to send (write) an item to a


queue within an ISR. In which, what is
pxHigherPriorityTaskWoken?
A. A pointer to the data to be copied into the queue.
B. If calling the API function causes a task to leave the
Blocked state, and the unblocked task has a priority higher
than the currently executing task (the task that was
interrupted), the API function will set
*pxHigherPriorityTaskWoken to pdFALSE.
C. The handle of the queue to which the data is being sent
(written).
(Đúng) D. If calling the API function causes a task to
leave the Blocked state, and the unblocked task has a
priority higher than the currently executing task (the
task that was interrupted), the API function will set
*pxHigherPriorityTaskWoken to pdTRUE.
E. A pointer to the memory into which the received data will
be copied.
Câu 30:

That is an API function used to receive (read) an item from a


queue. In which, what is xTicksToWait?
A. The handle of the queue to which the data is being sent
(written).
B. A pointer to the data to be copied into the queue.
(Đúng) C. The maximum amount of time the task
should remain in the Blocked state to wait for data to
become available on the queue, if the queue is already
empty.
D. A pointer to the memory into which the received data will
be copied.
E. The size in bytes of each data item that can be stored in
the queue.
Câu 31:
What’s on the serial monitor? (with
uxPriorityGet(xTask2Handle))
A. None of the others
B. Task is running with priority: 2
C. Task is running with priority: 1
D. Task is running with priority: 4
(Đúng) E. Task is running with priority: 3

Câu 32:

Below is the execution sequence for a hypothetical


application in which each task has been assigned a unique
priority. Which of the following statements are TRUE?
A. Task 2 is an event-driven and can preempt any other
task in the application.
B. Task 2 is a periodic task and gets preempted at t2, t7
and t12.
(Đúng) C. Task 1 is an event-driven and can preempt
any other task in the application.
(Đúng) D. The idle task gets preempted at t3, t5, and
t9.
(Đúng) E. Task 3 is an event-driven task and spends
most of its time in the Blocked state.
Câu 33:

That is an API function used to receive (read) an item from a


queue. In which, what is xQueue?
A. The maximum amount of time the task should remain in
the Blocked state to wait for data to become available on the
queue, if the queue is already empty.
B. A pointer to the memory into which the received data will
be copied.
C. The size in bytes of each data item that can be stored in
the queue.
(Đúng) D. The handle of the queue to which the data
is being received (read).
E. A pointer to the data to be copied into the queue.
Câu 34:

The taskYIELD() is a macro that can be called in a task to


request a context switch. The portYIELD_FROM_ISR() is an
interrupt safe version of taskYIELD(). What is the following is
TRUE?
A. The xHigherPriorityTaskWoken parameter is the same to
the pxHigherPriorityTaskWoken parameter used in
xQueueSendToBackFromISR.
B. A few FreeRTOS ports allow portYIELD_FROM_ISR() to be
called within an ISR.
C. If the xHigherPriorityTaskWoken parameter is pdFALSE
(zero), then a context switch is requested.
(Đúng) D. If the xHigherPriorityTaskWoken
parameter is not pdFALSE, then a context switch is
requested, and the task in the Running state might
change.
Câu 35: Until now, which of the followings is (are) in
FreeRTOS?
(Đúng) A. Event Groups
(Đúng) B. Software Timers
(Đúng) C. Tasks
(Đúng) D. Binary Semaphores
(Đúng) E. Mutexes
(Đúng) F. Task Notifications
(Đúng) G. Queue Sets
(Đúng) H. Queues
(Đúng) I. Counting Semaphores
Câu 36:

That is an API function used to send data to the back of a


queue. In which, what is xTicksToWait?
A. The size in bytes of each data item that can be stored in
the queue.
B. The handle of the queue to which the data is being sent
(written).
(Đúng) C. The maximum amount of time the task
should remain in the Blocked state to wait for space to
become available on the queue, should the queue
already be full.
D. A pointer to the memory into which the received data will
be copied.
E. A pointer to the data to be copied into the queue.
Câu 37: That is an API function used to create a task. In
which, what is pvParameters?
A. The Task Handler which is used to call the task for
various operations
(Đúng) B. A value that is passed as the parameter to
the created task.
C. The number of words to allocate for use as the task's
stack.
D. The priority at which the created task will get.
E. A descriptive name for the task
F. A C function that never exit and are implemented as an
infinite loop
Câu 38:

Assume that for a single queue, there are more than one task
blocked on it waiting for space. What happens when another
task or interrupt reads data from the queue?
A. The task that is unblocked is always the task that has
been waiting the longest.
B. None of the others
C. The task that is unblocked is always the highest priority
task that is waiting for space.
D. The task that is unblocked is always the highest priority
task that is waiting for space and has the longest 'block' time.
(Đúng) E. The task that is unblocked is always the
highest priority task that is waiting for space and has
been waiting the longest.
Câu 39: Which of the following statements about semaphore
and mutex are NOT TRUE?
(Đúng) A. Mutex and binary semaphore are the
same.
(Đúng) B. After a mutex is created, if a task ‘take’
the mutex, it always goes into the blocked state.
(Đúng) C. After a counting semaphore is created, if a
task ‘take’ the semaphore, it always goes into the
blocked state.
D. After a binary semaphore is created, if a task ‘take’ the
semaphore, it always goes into the blocked state.
E. A counting semaphore with maximum count 1 and initial
count 0 can be consider as an binary semaphore.

Câu 40: What is the API function that specifies a time at which
the task wishes to unblock relative to the time at which it is
called?
A. void vTaskDelayUntil( const TickType_t xTicksToDelay );
(Đúng) B. void vTaskDelay( const TickType_t
xTicksToDelay );
C. void vTaskDelay(TickType_t *pxPreviousWakeTime, const
TickType_t xTimeIncrement );
D. None of the others
E. void vTaskDelayUntil(TickType_t *pxPreviousWakeTime,
const TickType_t xTimeIncrement );

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy