How does PendSV occur during __disable_interrupt in xQueueSend function

Hi,

In xQueueSend (or xQueueGenericSend) function, __disable_interrupt is called, but after that, queueYIELD_IF_USING_PREEMPTION() is called while interrupt is disabling
with below comment

BaseType_t xQueueGenericSend(・・・)
{
    for( ; ; )
    {
        taskENTER_CRITICAL();
        {
                ・・・
                #else /* configUSE_QUEUE_SETS */
                {
                       ・・・
                        {
                            /* The unblocked task has a priority higher than
                             * our own so yield immediately.  Yes it is ok to do
                             * this from within the critical section - the kernel
                             * takes care of that. */
                            queueYIELD_IF_USING_PREEMPTION();
                        }
                }
        }
}

queueYIELD_IF_USING_PREEMPTION()

portYIELD_WITHIN_API()

portYIELD

vPortYield

/* Set a PendSV to request a context switch. */
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET;

Could you tell me how the kernel takes care of PendSV interrupt within the critical section?

On ports that use PENDV that gets disabled by the critical setion, the yield just won’t happen until the critical section ends, but that timing is ok here.

Other ports might switch right away, because the method of yieldin doesn’t need an interrupt, and the kermrl will make sure it is ok.

Thanks for your answer。