Giter VIP home page Giter VIP logo

Comments (4)

jlbirccyn avatar jlbirccyn commented on May 23, 2024

Hello,

You mean that the context switching is done by the PendSV handler I guess?

Best regards

from trampoline.

Nigelwz avatar Nigelwz commented on May 23, 2024

Yes, because I saw a lot of sample, the context switch all run on systick or timer.

from trampoline.

jlbirccyn avatar jlbirccyn commented on May 23, 2024

I still don't understand what you are saying. If the context switch occurs in the Systick or timer handler then it does not occur in the PendSV handler.

If you mean that the context switch occurs in the PendSV handler and the PendSV was triggered by the Systick or Timer handler then I don't see the point of invoking a PendSV rather than doing the context switch directly at the end of the Systick or Timer handler.

Also, I doubt that context switching is only done asynchronously in the handler of a hardware IT. When a synchronous system call leads to a context switch, it should be done immediately, not 1ms later (at worst).

from trampoline.

Nigelwz avatar Nigelwz commented on May 23, 2024

Thanks for your information!!
That's my first time to investigate the automotive indudtry.
Because sometime the "systick interrupt" and "hardware interrupt" can occur simultaneously , (e.g: uart, spi, button, hardware fault...), so some os can set the systick's priority be lower than other hardware interrupt, then if the systick triggered, it can enable the pendsv interrupt, then do context switch in pendsv.
Below is sample code..

void xPortSysTickHandler( void )
{
	/* The SysTick runs at the lowest interrupt priority, so when this interrupt
	executes all interrupts must be unmasked.  There is therefore no need to
	save and then restore the interrupt mask value as its value is already
	known.
	 */
	portDISABLE_INTERRUPTS();
	{
		/* 
		Increment the RTOS tick. 
		*/
		if( xTaskIncrementTick() != pdFALSE )
		{
			/* 
			A context switch is required.  Context switching is performed in
			the PendSV interrupt.  Pend the PendSV interrupt. 
			*/
			portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
		}
	}
	/*
	Enable interrupt, increntment pensv ISR.
	*/
	portENABLE_INTERRUPTS();
}
BaseType_t xTaskIncrementTick( void )
{
/// do context switch....
}

Or we just need to set ISR1 or ISR2 on trampline, is it correct?

from trampoline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.