To initialize and start Sirius RTOS, follow these steps:
The following example demonstrates the standard application code template used to initialize and launch the operating system:
#include "OS_API.h"
int main(void)
{
/* Initialization */
arInit();
stInit();
osInit();
/* TO DO: Create system objects, which you will use */
/* ... */
/* Start operating system */
osStart();
/* Deinitialization */
osDeinit();
arDeinit();
return 0;
}
The following example demonstrates the creation of the main task, which serves as the entry point and is the first task executed upon system startup. As this is a standard task, all system functions are fully available for use within its implementation.
#include "OS_API.h" ERROR MainTask(PVOID Arg) { /* TO DO: Write your application code here */ /* ... */ } int main(void) { /* Initialization */ arInit(); stInit(); osInit(); /* Create a main task (default stack size, the highest priority) */ osCreateTask(MainTask, NULL, 0, 0, FALSE); /* Start operating system */ osStart(); /* Deinitialization */ osDeinit(); arDeinit(); return 0; }
When osStart is called, the system begins execution immediately. The operating system can be stopped at any time using the osStop function. Upon calling this, all tasks are suspended, and program execution resumes from the first instruction following the osStart call that originally launched the system.
While the system execution is stopped, interrupts continue to be serviced. Operations performed on system objects will still execute successfully-for instance, data will continue to be queued in buffers-but tasks themselves will not be scheduled for execution. When osStart is called again, the scheduler resumes and determines which task should be the first to run.