* @brief This function will restore all cpus's scheduler and restore local irq. * * @param level is interrupt status returned by rt_cpus_lock(). * * @note This function only has MP version. */
| 204 | * @note This function only has MP version. |
| 205 | */ |
| 206 | void rt_cpus_unlock(rt_base_t level) |
| 207 | { |
| 208 | struct rt_cpu* pcpu = rt_cpu_self(); |
| 209 | |
| 210 | if (pcpu->current_thread != RT_NULL) |
| 211 | { |
| 212 | rt_base_t critical_level = 0; |
| 213 | RT_ASSERT(rt_atomic_load(&(pcpu->current_thread->cpus_lock_nest)) > 0); |
| 214 | rt_atomic_sub(&(pcpu->current_thread->cpus_lock_nest), 1); |
| 215 | |
| 216 | if (pcpu->current_thread->cpus_lock_nest == 0) |
| 217 | { |
| 218 | #if defined(RT_DEBUGING_SPINLOCK) |
| 219 | _cpus_lock_owner = __OWNER_MAGIC; |
| 220 | _cpus_lock_pc = RT_NULL; |
| 221 | #endif /* RT_DEBUGING_SPINLOCK */ |
| 222 | #ifdef RT_USING_DEBUG |
| 223 | critical_level = _cpus_critical_level; |
| 224 | _cpus_critical_level = 0; |
| 225 | #endif /* RT_USING_DEBUG */ |
| 226 | rt_hw_spin_unlock(&_cpus_lock); |
| 227 | rt_exit_critical_safe(critical_level); |
| 228 | } |
| 229 | } |
| 230 | rt_hw_local_irq_enable(level); |
| 231 | } |
| 232 | RTM_EXPORT(rt_cpus_unlock); |
| 233 | |
| 234 | /** |