# Quitting the scheduler loop \[xtensa\] \[\_frxt\_dispatch\]

**URL:** <https://forums.freertos.org/t/quitting-the-scheduler-loop-xtensa-frxt-dispatch/7692>\
**Category:** Kernel\
**Created:** [February 26, 2019, 9:50am UTC](https://forums.freertos.org/t/quitting-the-scheduler-loop-xtensa-frxt-dispatch/7692 "2019-02-26T09:50:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 26, 2019, 9:50am UTC](https://forums.freertos.org/t/quitting-the-scheduler-loop-xtensa-frxt-dispatch/7692/1 "2019-02-26T09:50:55Z")

</div>

**[guido-roncarolo](https://sourceforge.net/u/guido-roncarolo/)** wrote on [Tuesday, February 26, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/8070e8427c/#bf56):

I have a question related to quitting the scheduler loop in the Xtensa FreeRTOS port:

Freertos doc says that in order to quit the RTOS scheduling loop vTaskEndScheduler must be called  
Please see [https://www.freertos.org/a00133.html](https://www.freertos.org/a00133.html)

vTaskEndScheduler is implemented in term of vPortEndScheduler

Xtensa port has this implementation for vPortEndScheduler  
void vPortEndScheduler( void )  
{  
/\* It is unlikely that the Xtensa port will get stopped. If required simply  
disable the tick interrupt here. \*/  
}

Having ask my HW buddy, the tick interrupt for us is interrupt 2 and 3,

```auto
 Interrupt | Type |Level | BInterrupt | Pin Source 
----------+--------+------+------------+-----------
0 | Level | 1 | 0 | Tied low 
1 | Edge | 3 | 1 | Tied low
2 | Timer.0| 2 | | Internal
3 | Timer.1| 3 | | Internal

```

so I did something like this

```auto
void vPortEndScheduler( void )
{
    /* It is unlikely that the Xtensa port will get stopped. If required simply
    disable the tick interrupt here. */
    uint32_t ints = xthal_get_intenable();
    __dsp_printf("1) xthal_get_intenable 0x%x\n", ints);
 
    xt_ints_off(1 << 2);
    xt_ints_off(1 << 3);
    ints = xthal_get_intenable();
    __dsp_printf("2) xthal_get_intenable 0x%x\n", ints);
}

```

that gives me

```auto
1) xthal_get_intenable 0x4
2) xthal_get_intenable 0x0

```

So it would seem that the interrupt is OFF.

Unfortunately` _frxt_dispatch` keeps running.

Am I making a mistake?  
Would it be possible to have you guys double check this, please?

Thanks in advance

guido

---

<div class="post-metadata">

**Author:** ![McuOnEclipse](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/mcuoneclipse/32/32_2.png) [@McuOnEclipse](https://forums.freertos.org/u/McuOnEclipse)\
**Post date:** [February 26, 2019, 10:49am UTC](https://forums.freertos.org/t/quitting-the-scheduler-loop-xtensa-frxt-dispatch/7692/2 "2019-02-26T10:49:31Z")

</div>

**[xz8987f](https://sourceforge.net/u/xz8987f/)** wrote on [Tuesday, February 26, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/8070e8427c/#3de4):

Hi guido,  
I have implemented ending the scheduler for several microcontrollers. Basically I’m using a combination of setjmp and longjmp. I have documented it in [https://mcuoneclipse.com/2019/01/20/freertos-how-to-end-and-restart-the-scheduler/](https://mcuoneclipse.com/2019/01/20/freertos-how-to-end-and-restart-the-scheduler/) which has links to the implementation on GitHub. I think you can do the same for your port.

I hope this helps,  
Erich

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 27, 2019, 7:40am UTC](https://forums.freertos.org/t/quitting-the-scheduler-loop-xtensa-frxt-dispatch/7692/3 "2019-02-27T07:40:05Z")

</div>

**[guido-roncarolo](https://sourceforge.net/u/guido-roncarolo/)** wrote on [Wednesday, February 27, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/8070e8427c/#3de4/fb1d):

Hello Erich!

Thanks so much for the very detail and well documented work you did: I tested on my xtensa hifi4 and does work OK!

Thank you so much

guido
