I have a question about how or when configure interrupts using RTX in unprivileged mode, The question is: 1 - What happens if the program goes into an interrupt which uses OS directives before the OS is initialized?
I'm using a MDK-ARM + ver4.53 STM32F4 and this is a piece of pseudo code to illustrate my doubt.
int main(void) { //initialize the timer to generate an interrupt every 1ms TIM4_Config(); PeriphX_Config(); // All peripherals generate interrupts PeriphY_Config(); // PeriphZ_Config(); // // What happens if the program takes more than 1ms to reach this point? os_sys_init(task1); } __task void task1(void) { while(1){ //Wait event os_evt_wait_or (0x0008, 0xFFFF); // do something } } void TIM4_IRQHandler(void){ //Send event isr_evt_set (0x0008, task1); TIM_ClearITPendingBit(TIM4, TIM_IT_Update); }
The traditional way is to have a "dummy" main() that initializes the OS and creates one task that initializes everything and then creates all the other tasks.
That means that your startup file can use a small stack for main().
What happens if the program goes into an interrupt which uses OS directives before the OS is initialized?
Almost certainly nothing you would want to know about. So don't do that, period.
Almost certainly nothing you would want to know about.
Yes, it's always worth hiding critical information. Better to pretend it can't happen.
I will not waste any more time discussing something that your small brain will be incapable of understanding. Goodbye.
"What happens if the program goes into an interrupt which uses OS directives before the OS is initialized?"
Most likely a program failure. Better to check if OS is started before any reference to OS functions from interrupts.
thanks for your answer, but that approach doesn't work in unprivileged mode because in that mode a task can't modified the NVIC registers, then the interrupt configuration must be done in the "dummy" main and then initialize the OS. i never use a RTOS before, and i think i not explain well my question, my goal is not to use OS directives before initialize the OS, in fact i suppose that the program makes kaput. What i want is an approach to configure interrupts in unprivileged mode. My solution was configure all the interrupts and then start the OS, but in the process i ask myself: what happens if an interrupt is triggered before the OS is initialized? I search in all the documentation and old post in this forum and don't find the answer. I suppose one solution is to ensure that the time it takes to generate an interrupt is always greater than the time it takes the whole configuration code to run and initialize the OS. But I would like to hear other ideas. Thank for your time.
One thing to consider is that initializing interrupts isn't the same as enabling interrupts.
So you should be able to initialize all interrupts and then start RTX. Then in that first thread, you can turn on all your interrupts - see the SVC (supervisor call) instruction.
Of course, the interrupt enable/disable register are in an accessible part of the memory. I will try that, thanks for the tip.