H12-111_V2-5 practice question 13 of 25

When a task is suspended. If the current task is locked, it cannot be suspended.

Full set: 176 questions
Answer options
A: Correct Correct answer
B: Error
Correct Answer:
A. Correct
Explanation

In a real-time operating system (RTOS) like Huawei LiteOS, task locking (e.g., via LOSTaskLock()) is a mechanism that disables the task scheduler. The primary purpose of this is to allow a task to execute a critical section of code without being preempted by other tasks. Since suspending the currently running task would require the scheduler to perform a context switch to another ready task, and the scheduler is explicitly locked to prevent this, the current task cannot be suspended while it holds the lock.

Why Incorrect

B. This is incorrect. The fundamental principle of a scheduler lock is to prevent context switches, and suspending the current task necessitates a context switch.

References

1. Huawei. LiteOS Kernel Developer Guide. Section "Task Management," subsection "Locking Task Scheduling." The documentation explains that LOSTaskLock disables task scheduling to ensure the current task is not preempted. Any operation that would yield the CPU, such as suspension, is incompatible with this state.

2. Wang, K., & Xiong, W. (2019). Huawei LiteOS Kernel Architecture and Implementation. Chapter 4 "Task Management," describes the task scheduling lock mechanism, stating it prevents the scheduler from dispatching tasks, thus making the current task unable to be suspended or blocked.

Scroll to Top