whynotwhynot wrote on Thursday, July 17, 2008:
Thank you very much for your inputs and it helps a lot for me, a newbie. I still have some questions as below,
> To may understanding, at each Systick, the handler sent
> out a PendSV request and forced a context switch. Is this
> argument correct?
Yes - the PendSV holds pending until there are not higher priority interrupts running, then runs to select the next task.
So in the simple case (for example, no other interrupts), no matter what, the PendSV forced a context switch at every tick?
In some case, if there is an interrupt handler lasts more than a tick period. What will be the PendSV and SysTick? Is SysTick still updating? PendSV still initiates? Can they be nested?
Another situation is, if there is a running task and an interrupt is happened; and during the interrupt handler, some higher priority task is ready. What will the system do?
1) intermediately switch to higher priority task during the interrupt handler?
2) Continue to finish interrupt handler first and then return to old task. Then switch to high priority task?
> Isnt this going to waste the processor
> time? For example, if Fsystick=1kHz, is the processor going
> to check for and force for context switch for 1000 times in a
> second? Is there a way for it not switch if it does not need to?
You can of course set the tick speed down. 1KHz is used by the demos primarily for test purposes. It is much faster than nearly all applications require.
You could add code to set a flag when there is a context switch required.
> What is the CriticalNextingCount do?
Critical sections can nest, the critical section nesting count keeps track of the nesting depth and ensures that interrupts are only re-enabled when the nesting count unwinds back to zero. In other words, if two calls to portENTER_CRITICAL() follow each other, then interrupts should not be re-enabled fully until two calls to portEXIT_CRITICAL() have also been made.
So this is only for critical section? How critical section is related with a task? And I notice it is included in the TCB definition. Is there a purpose for that? Any example.
By the way, do we nest the interrupt in the FreeRTOS?Is there any programming model on this topic?
> If there is an interrupt during a task, does the
> interrupts processing time being counted as part of the task?
> Does Systick still increase during the interrupt handler?
The system timer itself increments all the time as it is driven directly from the clock. It is free running no matter what the software is doing.
What about the systick interrupt? Is it the lowest priority? Can the other interrupt pre-empt it? What it will do in that case, a higher priority interrupt handler keeps a long time greater than the tick period?
> What is the SVC 0 mean when start the first task?
This is a software interrupt, it puts the processor into the correct state for the first task to be started. You can look up the SVC instruction in the Cortex manual.
Can you give me a general idea of the SVC in Cortex port? What is the general function in that SVChandler?
> Anyway, is there a book by Richard on FreeRTOS?
Any Other tutorial to give a good start on the fundamentals? Can I get a systematic idea of the whole thing.