
+ + + + + + + + + + +
+ + + + +
Q
What types of MCUs does μC/OS support?
A
μC/OS-II & μC/OS-III currently support more than 40 processor architectures, and example projects can be downloaded from here.
Q
How to calculate the stack size for each task?
A
The required stack size for each task is application-dependent and can be obtained through manual calculation considering the memory required for function call nesting, register context, and interrupt handling. For detailed information, refer to How to Set the Stack Size for Application Tasks?
Q
Does μC/OS have an alarm function for stack memory overflow?
A
Task stacks can utilize processor features such as MPU/MMU and hardware stack limit registers for stack overflow detection. On the software side, uC/OS-II & uC/OS-III provide software stack checking functions. For specific implementations, refer to: https://micrium.atlassian.net/wiki/spaces/osiidoc/pages/163900/Task+Management and https://micrium.atlassian.net/wiki/spaces/osiiidoc/pages/132411/Detecting+Task+Stack+Overflows
Q
What is the memory allocation mechanism of μC/OS?
A
The μC/OS kernel provides a fixed block size storage management mechanism for kernel objects and task stack space, implemented based on static allocation.
Q
Is the stack of each task at a fixed address?
A
By default, the stack address for each task is determined by the linker during the linking stage.
Q
In multi-core applications, if one CPU is responsible for one task, what strategy does the RTOS use to allocate task execution? Does it need to consider task priority?
A
In SMP systems, various strategies can be used to allocate task execution. By using the RTOS affinity feature, a task can be set to run on a specific CPU. In SMP systems, the RTOS knows all ready-to-run tasks and aims to run tasks on all cores whenever possible, unless a specific CPU affinity has been set for that task, which would prevent it from running. This is how priority is set. The same principle applies to multi-core CPUs, where tasks are prioritized just like in single-core systems. In a four-core system, the four most important tasks will run simultaneously.
Q
How does μC/OS system wake up after a task receives communication?
A
All tasks are managed by the μC/OS kernel, and the occurrence of communication will change the state of the task. μC/OS uses a preemptive scheduling strategy to wake up the highest priority ready task for execution.
Q
If data communication is not complete and the MCU processes another more urgent task, can that task continue data communication after completion? What scheduling method does μC/OS use to handle such tasks?
A
Based on μC/OS applications, the kernel provides a queue mechanism for asynchronous data interaction between interrupts and tasks or between tasks. Through the context switching mechanism provided by μC/OS, the execution context of the preempted task is correctly maintained, allowing the task to resume execution from the preempted position when it is run again.
Q
Are event flag groups associated with tasks or RTOS?
A
Event groups are kernel objects created by the application and managed by the RTOS. Tasks or ISRs can set or clear bits in the event group. Only tasks can wait for bits to be set or cleared.
Q
Does μC/OS support time-slicing and preemptive scheduling algorithms?
A
μC/OS-III supports preemptive scheduling and time-slicing algorithms, allowing multiple tasks to set the same priority level, with each task’s time slice length configurable individually. μC/OS-II only supports preemptive scheduling, and each task’s priority must be unique.
Q
When an interrupt occurs, is the interrupt context saved to the interrupted task’s stack? Does this pose a risk of stack overflow?
A
If the system does not have an independent interrupt stack, the context will be saved to the interrupted task’s stack when an interrupt occurs. If insufficient RAM space is allocated for the task stack, a stack overflow will occur. Therefore, when allocating task stacks, possible interrupt nesting should be considered, and sufficient stack space should be allocated.
Q
How to configure a lower priority task that may require urgent response and gain higher priority during execution? Can this be achieved by disabling interrupts?
A
Many RTOS provide APIs to change task priorities, such as OSTaskChangePrio() in uC/OS-III, which sets the new task priority level. If the priority only needs to be elevated above certain tasks, it is not necessary to use interrupt disabling. If the task needs to be at the highest priority and the time is very short, disabling interrupts can be used, but the interrupt handling time must be very short to avoid affecting the overall system response time.
Q
Does the delay() function block waiting occupy CPU?
A
When a task calls a delay function, it will be blocked, and the CPU will look for the next highest priority ready task to execute. The delay function does not block the CPU; it only stops the current task’s execution. The system uses a timer to count down, and when the delay time is up, the task is woken up again.
Q
How does the RTOS ensure deadlines are met?
A
Many techniques can help applications meet their deadline requirements, such as Rate Monotonic Scheduling (RMS) and Rate Monotonic Analysis (RMA). RMS requires a preemptive scheduler like uC/OS-III, and not all tasks have strict deadlines; some tasks may not complete before their deadlines but will not cause system issues.
Q
How to choose a suitable RTOS?
A
The choice of RTOS depends on the requirements:
1. Use open-source version or commercial solution?
2. Is software quality a concern?
3. Does the RTOS support the CPU architecture in use?
4. Is the quality of RTOS documentation a concern?
Q
What is the difference between hard real-time OS and soft real-time OS? How to determine if it is a hard real-time system?
A
A hard real-time system is one that cannot miss any (hard) deadlines; otherwise, catastrophic consequences will occur. Soft real-time means missing deadlines does not lead to severe consequences. Most systems are a combination of hard and soft requirements. Usually, only a few tasks have strict deadlines, and the highest priority should be assigned to those tasks in applications.
Q
What is the difference in using Mutex in single-core and multi-core CPUs?
A
From the application’s perspective, the behavior of mutexes on single-core or multi-core CPUs is the same. However, depending on the implementation of the multi-core RTOS, if the owner of the mutex needs to elevate priority, it may lead to a “kernel change”. However, this is transparent to the application code.
Q
What is the difference in using Mutex in single-core and multi-core CPUs?
A
From the application’s perspective, the behavior of mutexes on single-core or multi-core CPUs is the same. However, depending on the implementation of the multi-core RTOS, if the owner of the mutex needs to elevate priority, it may lead to a “kernel change”. However, this is transparent to the application code.
Video playback: Click the image below to enter
Please follow the latest updates and training news from the “Micrium Technology” WeChat public account.
WeChat consultation: bmrtech123
