[riot-devel] thread_yeild

Hauke Petersen hauke.petersen at fu-berlin.de
Mon Sep 1 13:38:45 CEST 2014

Hi Abhinav,

the situation for the cortex-mx platforms is sligthly more complicated:

The `thread_yield()` call tells the controller to trigger the PendSV 
interrupt. This ISR has the property, that it is executed after all 
(higher prioritized) active interrupts are serviced first. In the PendSV 
handler the actual context switching takes place and the controller is 
then put back into `normal` thread mode (see `thread_arch.c` in the 
`cortex-mX_common` folders`. But I guess the effect stays the same: 
calling `thread_yield()` will trigger a context switch (if applicable) 
and the resulting thread is always run in non-interrupt mode.


On 01.09.2014 11:45, Thomas Eichinger wrote:
> Dear Abhinav,
> `thread_yield()` is used a lot in the periph drivers for i.e. stm32f*
> CPUs in the following manner.
> ```C
> ...
> if (sched_context_switch_request) {
>      thread_yield()
> }
> ```
> This way the scheduler performs a thread change (if requested) then
> the ISR is finished and returns from interrupt context into the newly
> scheduled thread.
> Hope this helps!
> Best, Thomas
> On 1 Sep 2014, at 11:25 CEST(+0200), Somaraju Abhinav wrote:
>> Hello,
>> if the thread_yeild function is called from within an ISR, then when
>> does the program exit the ISR. Does the scheduler make sure that we exit
>> the ISR before running the new thread or do we continue to be in the
>> ISR?
>> Thanks a lot for the help!
>> Regards,
>> Abhinav
>> ________________________________________________________
>> The contents of this e-mail and any attachments are confidential
>> to the intended recipient. They may not be disclosed to or used
>> by or copied in any way by anyone other than the intended recipient.
>> If this e-mail is received in error, please immediately notify
>> the sender and delete the e-mail and attached documents.
>> Please note that neither the sender nor the sender's company
>> accept any responsibility for viruses and it is your responsibility
>> to scan or otherwise check this e-mail and any attachments.
>> _______________________________________________
>> devel mailing list
>> devel at riot-os.org
>> http://lists.riot-os.org/mailman/listinfo/devel
> _______________________________________________
> devel mailing list
> devel at riot-os.org
> http://lists.riot-os.org/mailman/listinfo/devel

More information about the devel mailing list