Académique Documents
Professionnel Documents
Culture Documents
G Anand
anandg.embedd@gmail.com
ARTOS 2016
FEATURES
Task Priority
All the task ruined at least one time in every kernel routine (Total Task
switching)
LOW: This priority tasks will be called once after HIGH priority
task. It works on the basis of auto task switching. Every time the task
can be switched between TMR0 interrupt act. If for loop based delay
is used in the task, then it will be difficult to predict the time because
of auto switching process. In-order to avoid the task switching in the
task in which for loop is used, ARTOS_LOCK () function can be
used.
HIGH: This priority tasks will be called once before LOW priority
task. It works on the basis of auto task switching. Every time the task
can be switched between TMR0 interrupt act. If for loop based delay
is used in the task, then it will be difficult to predict the time because
of auto switching process. In-order to avoid the task switching in the
task in which for loop is used, ARTOS_LOCK () function can be
used.
REALTIME: This priority tasks will be called multiple times after
each HIGH and LOW priority tasks. Its used to debugger task for
fetch task status from each calling task. It is a Controlled task. It
works on the basis of manual task switching. If once the task resource
is allocated to real time priority tasks, then the process will not move
to another task. If there is a need to switch the task, then use
ARTOS_Idle () function (switching to the next task).
ARTOS 2016
Semaphore
All processors internal resources are accessed by semaphore.
Example: Consider the processor has single serial port. If the same
resource is accessed by 2 tasks simultaneously, then data interference
will be occurred in serial port.
To avoid this CONNECT and DISCONNECT instructions can be
used. If one task is already connected to the serial port, other tasks
should wait to establish connection to that resource.
Interrupt Handling
Easy to access interrupt functions
All interrupts are enabled and disabled by inbuilt functions and
interrupt event handles header functions.
Software nested interrupt sequence
Interrupt Priority
LOW: Handle has individual stack. It processes newly arrived
LOW and HIGH priority interrupts. If HIGH or LOW interrupt
comes into play while one low priority interrupt is in process,
then current interrupt context has been saved and jump to next
ARTOS 2016
UART function
Interrupt based TX an RX
Buffered receiver which doesnt listen every time while receiving
Semaphore based UART functions like sending and receiving
operations using byte and string.
System Timer
Inbuilt HR: MIN: SEC: MSEC: USEC task for perfect timer
operation.
Get system time sample for timeout operation.
Use Kernel Timer (TMR0) , so dont need special timer
ARTOS 2016
FUNCTIONS
int8
ARTOS_Init(uint16
Main_ThreadID,int8 *Main_Stack,uint16
Main_Stack_Depth,uint8 Main_Task_Priority);
This function should be called before calling other functions (i.e at
initial stage). In our ARTOS, creation and implementation of tasks are
performed simultaneously. For this simultaneous operation init function
should be declared at first. Consider the main function consists of 2 tasks.
Main()
{
ARTOS 2016
int8
ARTOS_Init(uint16
Main_ThreadID,int8 *Main_Stack,uint16
Main_Stack_Depth,uint8 Main_Task_Priority);
Task 1
----------------------Task 2
}
Used to back up the main task context
First task 1 will be created and implemented initially. Task 1 will be
interrupted after particular time delay and the program control switch into
task 2 creation and implementation. This will be interrupted after particular
time delay and the program control has switched to task 1. Thus the
simultaneous operation can be achieved.
Default delay time is 500 micro seconds. We can change this delay
time according to our need. In other versions of RTOS first we should create
task in the main function. Only after creation of all tasks OS starts to
implement them. If the OS starts to implement the tasks, then it will never
return to the main function.
To declare init function we need to assign thread ID(uint16
Main_ThreadID),
stack
name(int8
*Main_Stack),
stack
size(uint16
ARTOS 2016
ARTOS 2016
start operation to implement that task. We can start any task from any step
using the ID of the task.
int8 ARTOS_Stop( uint16 Thread_ID );
This function is used to stop the implementation of the task. Normally
after particular delay, program control will be switched into another task.
Once the program control get the stop command of particular task, then the
program control should not get into task until the task is started by using
start function We can stop any task from any step using the ID of the task.
int8 ARTOS_Delete( uint16 Thread_ID );
This function is used to delete the particular task using task ID(thread
ID). This function clear the memory associated with the task.
void ARTOS_Return();
This function is used to return the output of a function.
Return value = 0 indicates the output of a function has returned successfully
Return value = negative number indicates the return of output is
unsuccessful
void ARTOS_Idle();
This function is used to idle the function for one cycle.
Main()
{
ARTOS 2016
ARTOS 2016
It will get interrupted after particular delay time. Then the program control
will be switched into task 1. Then the
void ARTOS_Delay(uint16 delay_ms);
This function is used provide delay. We should pass delay time as
argument of this function.
void ARTOS_Lock();
Normally after particular delay, program control will be switched into
another task. Lock function is used to avoid this switching. So the program
control moved to next task only after completing the task which has lock
function. This will be helpful to avoid switching in-case of low and high
priority tasks.
void ARTOS_UnLock();
This function is used to unlock the task which was locked.
ARTOS 2016