level 11
huarkkk
楼主
摘自 uc/os III The Real-Time Kernel 用户手册
1. Disable/Enable Interrupts
When access to shared resource is very quick (reading from or writing to few variables) and access is faster than μC/OS-III’s interrupt disable time.
It is highly recommended to not use this method as it impacts interrupt latency.
2. Locking/Unlocking the Scheduler
When access time to the shared resource is longer than μC/OS-III’s interrupt disable time, but shorter than μC/OS-III’s scheduler lock time.
Locking the scheduler has the same effect as making the task that locks the scheduler the highest-priority task.
It is recommended not to use this method since it defeats the purpose of using μC/OS-III. However, it is a better method than disabling interrupts, as it does not impact interrupt latency.
3. Semaphores
When all tasks that need to access a shared resource do not have deadlines. This is because semaphores may cause unbounded priority inversions (described later). However, semaphore services are slightly faster (in execution time) than mutual-exclusion semaphores.
4. Mutual Exclusion Semaphores
This is the preferred method for accessing shared resources, especially if the tasks that need to access a shared resource have deadlines.
μC/OS-III’s mutual exclusion semaphores have a built-in priority inheritance mechanism, which avoids unbounded priority inversions.
However, mutual exclusion semaphore services are slightly slower (in execution time) than semaphores since the priority of the owner may need to be changed, which requires CPU processing.
一句话,推荐使用二值信号量,或者互斥型信号量。
二句话,互斥型信号量有优先级继承机制,略微占用一点CPU时间。
2016年01月11日 02点01分
1
1. Disable/Enable Interrupts
When access to shared resource is very quick (reading from or writing to few variables) and access is faster than μC/OS-III’s interrupt disable time.
It is highly recommended to not use this method as it impacts interrupt latency.
2. Locking/Unlocking the Scheduler
When access time to the shared resource is longer than μC/OS-III’s interrupt disable time, but shorter than μC/OS-III’s scheduler lock time.
Locking the scheduler has the same effect as making the task that locks the scheduler the highest-priority task.
It is recommended not to use this method since it defeats the purpose of using μC/OS-III. However, it is a better method than disabling interrupts, as it does not impact interrupt latency.
3. Semaphores
When all tasks that need to access a shared resource do not have deadlines. This is because semaphores may cause unbounded priority inversions (described later). However, semaphore services are slightly faster (in execution time) than mutual-exclusion semaphores.
4. Mutual Exclusion Semaphores
This is the preferred method for accessing shared resources, especially if the tasks that need to access a shared resource have deadlines.
μC/OS-III’s mutual exclusion semaphores have a built-in priority inheritance mechanism, which avoids unbounded priority inversions.
However, mutual exclusion semaphore services are slightly slower (in execution time) than semaphores since the priority of the owner may need to be changed, which requires CPU processing.
一句话,推荐使用二值信号量,或者互斥型信号量。
二句话,互斥型信号量有优先级继承机制,略微占用一点CPU时间。