why the reschrdule not permitted if lock key nested ?


HI guys:
  in kerne impl. many scenarios would call the z_reschedule to yield volunteer if the thread`s resource request did not meets.

but the "resched" condition check confuse me, it seems only the case that the l"z_arch_irq_unlocked" is true, which means the previous irq lock status is
unlock, can the schedule be permitted. in this case, the irq lock depth only 1 is permitted.
but Why design like this, in many rtos impl.  the voluteer yield operation can happen without care bout how depth the lock level, why zephyr need care about this?
static inline int resched(u32_t key)                                                                                                                                                                      |-
{                                                                                                                                                                                                         |-
#ifdef CONFIG_SMP                                                                                                                                                                                         |-
        if (!_current_cpu->swap_ok) {                                                                                                                                                                     |-
                return 0;                                                                                                                                                                                 |-
        }                                                                                                                                                                                                 |-
        _current_cpu->swap_ok = 0;                                                                                                                                                                        | 
#endif                                                                                                                                                                                                    | 
        return z_arch_irq_unlocked(key) && !z_is_in_isr();                                                                                                                                                | 
}                                                                                                                                                                                                         | 
void z_reschedule(struct k_spinlock *lock, k_spinlock_key_t key)                                                                                                                                          | 
{                                                                                                                                                                                                         |-
        if (resched(key.key)) {                                                                                                                                                                           |-
                z_swap(lock, key);                                                                                                                                                                        |-
        } else {                                                                                                                                                                                          |-
                k_spin_unlock(lock, key);                                                                                                                                                                 |-
        }                                                                                                                                                                                                 |-
}                                                                                                                                                                                                         |-


珠海全志科技股份有限公司      BU1-PSW




网址: http://www.allwinnertech.com


Join devel@lists.zephyrproject.org to automatically receive all group messages.