cancel
Showing results for 
Search instead for 
Did you mean: 

Custom RTOS - general ideas veryfication

Mark Twain
Associate II
Posted on December 13, 2017 at 11:50

The original post was too long to process during our migration. Please click on the attachment to read the original post.
9 REPLIES 9
Andrew Neil
Evangelist III
Posted on December 13, 2017 at 23:15

Cross-post - Keil forum:

http://www.keil.com/forum/63199

Posted on December 14, 2017 at 01:07

I don't want to rain on your parade, but the #1 best practice is 'don't write your own RTOS'.

Hopefully you will be getting a degree, or some feeling of a job well done, or education by fire.

A

Mark Twain
Associate II
Posted on December 14, 2017 at 08:04

Thanks for your answers ! Unfortunately, none of them was related to RTOS discussion

:(

Posted on December 14, 2017 at 07:47

Messages completely coincide, it's strange, the author did not have new ideas at the time of copying the text.

On the topic - for the use of critical sections it is necessary to beat the user with bamboo sticks. The number of strokes is not normalized, but limited by the level of enlightenment. The prohibition of interrupts is the greatest evil.

Posted on December 14, 2017 at 08:23

You need to study the process of preempting interrupts of different priorities.

You need two different stacks, for interrupts and for program flows.

All secondary register storages with simultaneous interrupts of different levels are stored in the interrupt stack area. You can make a lot of calls to new interrupts inside interrupts, and this will not affect the program stack.

But you can not switch tasks with an unknown pattern of the interrupt stack !! Switching call-the maximum priority level, will be executed when all more important interrupts have already been executed. Inside the switch call, an interrupt with zero priority is called. So that it was impossible to interrupt the update procedure of the task stack.

Posted on December 14, 2017 at 09:40

Inside the switch call, an interrupt with zero priority is called. So that it was impossible to interrupt the update procedure of the task stack.

Where did you get it from ?

freeRTOS is using

only

PendSV with priority 240 to save the context and switch tasks

:)

Posted on December 14, 2017 at 13:28

Where did my opinion come from?

I broke all my legs about crutches freeRTOS. And I had to write my OS.

https://bitbucket.org/AVI-crak/rtos-cortex-m3-gcc/commits/branch/default

I took for an example

https://www.segger.com/

.

Switching tasks is started by a timer or a direct call. The interruption from the timer has the highest priority, and it can be superseded by any other interrupt - so the purity of the stack is achieved.

A timer or direct call starts an interrupt with zero priority, in which the task is toggled. This interrupt can no longer be interrupted, and it is always performed without crutches. The interdiction interdiction is a crutch. All freeRTOS is one huge crutch.

And yet - the number of preemptive priority levels - only 16 pieces.

Posted on December 14, 2017 at 15:09

So you are suggesting to save/switch context inside high priority interrupt?

Im a little bit confused becouse all ARM documents stands that PendSV should be used as context switcher in os enviroment.

Posted on December 14, 2017 at 17:49

Task switching timer (maximum priority) -> PendSV (zero priority) task switching.

The lower the priority, the higher the resistance to displacement. Zero priority is not superseded. But if three or more interrupts with zero priority are triggered simultaneously, they are executed according to their level. For this reason, the zero priority for switching and the maximum for the timer must be unique. For the user, priorities 1-14 remain free. Each priority has 16 levels, or an ordered list. The interrupts that have been triggered (even in the preemptive state) will be processed according to this list.

When interrupts are disabled, the history of the events that are triggered is lost. They are explicitly prohibited, and do not queue for execution. If automatic data collection is used, then interrupting prohibits equilibrium.