4.7.2.6 Os_main/os_task Attribute
On AVR, functions with the OS_main or
OS_task attribute do not save/restore any call-saved register in
their prologue/epilogue.
The OS_main attribute can be used when there is
guarantee that interrupts are disabled at the time when the function is entered. This
saves resources when the stack pointer has to be changed to set up a frame for local
variables.
The OS_task attribute can be used when there is no
guarantee that interrupts are disabled at that time when the function is entered like
for, e.g. task functions in a multi-threading operating system. In that case, changing
the stack pointer register is guarded by save/clear/restore of the global interrupt
enable flag.
void __attribute__((OS_main)) foo ();
void __attribute__((OS_task)) bar();- naked functions do not have a return instruction whereas
OS_mainandOS_taskfunctions have aretorretireturn instruction. - naked functions do not set up a frame for local variables or a
frame pointer whereas
OS_mainandOS_taskdo this as needed.
