Table of Contents

ALL OSA SERVICES

The third column of the table shows the service's properties:

Service uses system timer
Do not call from ISR
Call from task only
Allowed calls only from task and functions called by task (any depth)
Switches context
Call from ISR only
Has alternate service for use in ISR (suffix "_I")

System services

Service Arguments Description Properties
System
OS_Sched Scan all tasks, select ready task with the highest priority and run it
OS_Run Run operating system's kernel. Calls OS_Sched() in infinite loop
OS_Init Initialize system variables Not allowed in interrupt
OS_Timer Increase all active timers
Waiting
OS_Yield Return to the scheduler Allowed only in taskSwitches context
OS_Delay (delaytime) Delay current task for delaytime system ticks Allowed only in taskSwitches contextService uses system timer
OS_Wait (condition) Wait for condition to become true Allowed only in taskSwitches context
OS_Wait_TO (condition, timeout) Wait for condition to become true. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer
Checking
bool
OS_IsTimeout
Return true if timeout occurred in previous wait service Service uses system timer
bool
OS_IsError
Check for error after task creation
bool
OS_IsEventError
Check for error after using events
bool
OS_IsInCriticalSection
Return true if any task is in critical section
Interrupts
OS_EnterInt For PICC16 and PICC18: save FSR at the beginning of ISR function Only inside interrupt
OS_LeaveInt For PICC16 and PICC18: restore saved FSR at the end of ISR function Only inside interrupt
char
OS_DI
Disable all interrupts and save previous state of GIEx flags Not allowed in interrupt
OS_EI Enable all interrupts Not allowed in interrupt
OS_RI (char) Restore GIEx flags previously saved by OS_DI service Not allowed in interrupt
OS_EnterCriticalSection Enter critical section Allowed only in task
OS_LeaveCriticalSection Leave critical section Allowed only in task

Task control

Service Arguments Description Properties
Creating/Deleting
OS_Task_Define (TaskName) For CCS: Tell compiler that function TaskName is a task and it will be called indirectly. This service is called from main() only main
OS_Task_Create (priority, TaskName) Create task from function TaskName and add it to the list of active tasks Not allowed in interrupt
OS_Task_Replace (priority, TaskName) Stop and delete current task and create a new task from function TaskName Allowed only in task
OS_Task_Delete (tp) Delete task Switches context
Management
OST_TASK_POINTER
OS_Task_GetCur
Get pointer to current task's descriptor Allowed only in task
OST_TASK_POINTER
OS_Task_GetCreated
Get pointer to just-created task's descriptor
OS_Task_Pause (tp) Pause task Switches context
OS_Task_Continue (tp) Continue paused task
char
OS_Task_GetPriority
(tp) Get priority of task
OS_Task_SetPriority (tp, priority) Change task's priority
Checking
OS_Task_IsPaused (tp) Check if task is paused

Binary semaphores

Service Arguments Description Properties
Management
OS_Bsem_Set (bsem) Signal binary semaphore Has alternate service for use in ISR (suffix "_I")
OS_Bsem_Reset (bsem) Reset binary semaphore Has alternate service for use in ISR (suffix "_I")
OS_Bsem_Switch (bsem) Change binary semaphore's state Has alternate service for use in ISR (suffix "_I")
Checking
OST_WORD
OS_Bsem_Check
(bsem) Check if binary semaphore is set Has alternate service for use in ISR (suffix "_I")
Waiting
OS_Bsem_Wait (bsem) Wait for binary semaphore to be set Allowed only in taskSwitches context
OS_Bsem_Wait_TO (bsem, timeout) Wait for binary semaphore to be set. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer

Counting semaphores

Service Arguments Description Properties
Creating
OS_Csem_Create (csem) Create and zero counting semaphore Not allowed in interrupt
Management
OS_Csem_Signal (csem) Increase counting semaphore's value by 1 (wait if overflow) Allowed only in taskSwitches context
OS_Csem_Signal_Now (csem) Increase counting semaphore's value by 1 (don't wait if overflow) Has alternate service for use in ISR (suffix "_I")
OS_Csem_Set (csem) Set counting semaphore's value to 1 Has alternate service for use in ISR (suffix "_I")
OS_Csem_SetValue (csem, value) Set counting semaphore's value to a given value Has alternate service for use in ISR (suffix "_I")
OS_Csem_Reset (csem) Zero counting semaphore Has alternate service for use in ISR (suffix "_I")
Checking
bool
OS_Csem_Check
(csem) Check if counting semaphore is set (non-zero) Has alternate service for use in ISR (suffix "_I")
OS_Csem_Accept (csem) Accept counting semaphore. Decrease its value by 1 Has alternate service for use in ISR (suffix "_I")
Waiting
OS_Csem_Wait (csem) Wait for counting semaphore. Then decrease its value by 1 Allowed only in taskSwitches context
OS_Csem_Wait_TO (csem, timeout) Wait for counting semaphore. Then decrease its value by 1. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer

Pointers to messages

Service Arguments Description Properties
Creating
OS_Msg_Create (msg_cb) Create a message control block and zero it Not allowed in interrupt
Sending
OS_Msg_Send (msg_cb, message) Send message. If message already exists then wait until it becomes free Allowed only in taskSwitches context
OS_Msg_Send_TO (msg_cb, message, timeout) Send message. If message already exists then wait until it becomes free. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer
OS_Msg_Send_Now (msg_cb, message) Send message. If message already exists then it will be overwritten Has alternate service for use in ISR (suffix "_I")
Checking
bool
OS_Msg_Check
(msg_cb) Check if message exists Has alternate service for use in ISR (suffix "_I")
OS_Msg_Accept (msg_cb, os_msg_type_var) Accept existing message. After accepting, message is freed Has alternate service for use in ISR (suffix "_I")
Waiting
OS_Msg_Wait (msg_cb, os_msg_type_var) Wait for message. After waiting, message is freed Allowed only in taskSwitches context
OS_Msg_Wait_TO (msg_cb, os_msg_type_var, timeout) Wait for message. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer

Simple messages

Service Arguments Description Properties
Creating
OS_Smsg_Create (smsg) Create and zero a simple message
Sending
OS_Smsg_Send (smsg, smessage) Send a simple message. If message already exists then wait until it becomes free Allowed only in taskSwitches context
OS_Smsg_Send_TO (smsg, smessage, timeout) Send a simple message. If message already exists then wait until it becomes free. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer
OS_Smsg_Send_Now (smsg, smessage) Send a simple message. If message already exists then it will be overwritten Has alternate service for use in ISR (suffix "_I")
Checking
bool
OS_Smsg_Check
(smsg) Check if simple message exists Has alternate service for use in ISR (suffix "_I")
OS_Smsg_Accept (smsg, os_smsg_type_var) Accept existing simple message. After accepting, message is cleared Has alternate service for use in ISR (suffix "_I")
Waiting
OS_Smsg_Wait (smsg, os_smsg_type_var) Wait for simple message. After accepting, simple message is cleared Allowed only in taskSwitches context
OS_Smsg_Wait_TO (smsg, os_smsg_type_var, timeout) Wait for simple message. After accepting, simple message is cleared. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer

Queue of pointers to messages

Service Arguments Description Properties
Creating
OS_Queue_Create (queue, buffer, size) Create and clear queue Not allowed in interrupt
Sending
OS_Queue_Send (queue, message) Send message via queue. If queue full then wait for free slot Allowed only in taskSwitches context
OS_Queue_Send_TO (queue, message, timeout) Send message via queue. If queue full then wait for free slot. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer
OS_Queue_Send_Now (queue, message) Send message via queue. If queue is full then oldest message will be dropped Has alternate service for use in ISR (suffix "_I")
Checking
bool
OS_Queue_Check
(queue) Check if there is any message in queue Has alternate service for use in ISR (suffix "_I")
bool
OS_Queue_IsFull
(queue) Check if queue of messages is full Has alternate service for use in ISR (suffix "_I")
bool
OS_Queue_IsEmpty
(queue) Check if queue of messages is empty Has alternate service for use in ISR (suffix "_I")
Waiting
OS_Queue_Wait (queue, os_msg_type_var) Wait for message from queue. After accepting message, it will be deleted from queue Allowed only in taskSwitches context
OS_Queue_Wait_TO (queue, os_msg_type_var, timeout) Wait for message from queue. After accepting message, it will be deleted from queue. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer

Queue of simple messages

Service Arguments Description Properties
Creating
OS_Squeue_Create (squeue, buffer, size) Create and clear queue Not allowed in interrupt
Sending
OS_Squeue_Send (squeue, smessage) Send simple message via queue. If queue full then wait for free slot Allowed only in taskSwitches context
OS_Squeue_Send_TO (squeue, smessage, timeout) Send message via queue. If queue full then wait for free slot. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer
OS_Squeue_Send_Now (squeue, smessage) Send message via queue. If queue is full then oldest message will be dropped Has alternate service for use in ISR (suffix "_I")
Checking
bool
OS_Squeue_Check
(squeue) Check if there is any simple message in queue Has alternate service for use in ISR (suffix "_I")
bool
OS_Squeue_IsFull
(squeue) Check if queue of simple messages is full. Has alternate service for use in ISR (suffix "_I")
bool
OS_Squeue_IsEmpty
(squeue) Check if queue of simple messages is empty Has alternate service for use in ISR (suffix "_I")
Waiting
OS_Squeue_Wait (squeue, os_smsg_type_var) Wait for a message from the queue. After accepting message, it will be deleted from queue Allowed only in taskSwitches context
OS_Squeue_Wait_TO (squeue, os_smsg_type_var, timeout) Wait a message from the queue. After accepting message, it will be deleted from queue. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer

Flags

Service Arguments Description Properties
Creating
OS_Flag_Create (flag) (flag = 0) Create flag and clear all its bits
Management
OS_Flag_Init (flag, value) (flag = value) Set flag to given value Has alternate service for use in ISR (suffix "_I")
OS_Flag_Set (flag, mask) (flag = flag | mask) Set bits in flag according to mask Has alternate service for use in ISR (suffix "_I")
OS_Flag_Clear (flag, mask) (flag &= ~mask) Clear bits in flag according to mask Has alternate service for use in ISR (suffix "_I")
Checking
bool
OS_Flag_Check_AllOn
(flag, mask) ( if ((flag & mask)==mask) ) Check if all bits in flag specified by mask are set Has alternate service for use in ISR (suffix "_I")
bool
OS_Flag_Check_On
(flag, mask) ( if ((flag & mask)!=0) ) Check if any bit in flag specified by mask is set Has alternate service for use in ISR (suffix "_I")
bool
OS_Flag_Check_AllOff
(flag, mask) ( if ((flag & mask)==0) ) Check if all bits in flag specified by mask are cleared Has alternate service for use in ISR (suffix "_I")
bool
OS_Flag_Check_Off
(flag, mask) ( if ((flag & mask)!=mask) ) Check if any bit in flag specified by mask is cleared Has alternate service for use in ISR (suffix "_I")
Waiting
OS_Flag_Wait_AllOn (flag, mask) ( if ((flag & mask)==mask) ) Wait until all bits in flag specified by mask are set Allowed only in taskSwitches context
OS_Flag_Wait_On (flag, mask) ( wait ((flag & mask)!=0) ) Wait until any bit in flag specified by mask is set Allowed only in taskSwitches context
OS_Flag_Wait_AllOff (flag, mask) ( wait ((flag & mask)==0) ) Wait until all bit in flag specified by mask are cleared Allowed only in taskSwitches context
OS_Flag_Wait_Off (flag, mask) ( wait ((flag & mask)!=mask) ) Wait until any bit in flag specified by mask is cleared Allowed only in taskSwitches context
OS_Flag_Wait_AllOn_TO (flag, mask, timeout) ( wait ((flag & mask)==mask) ) Wait until all bits in flag specified by mask are set. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer
OS_Flag_Wait_On_TO (flag, mask, timeout) ( wait ((flag & mask)!=0) ) Wait until any bit in flag specified by mask is set. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer
OS_Flag_Wait_AllOff_TO (flag, mask, timeout) ( wait ((flag & mask)==0) ) Wait until all bits in flag specified by mask are cleared. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer
OS_Flag_Wait_Off_TO (flag, mask, timeout) ( wait ((flag & mask)!=mask) ) Wait until any bit in flag specified by mask is cleared. Exit if timeout expired Allowed only in taskSwitches contextService uses system timer

Timers

Task timers

Service Arguments Description Properties
Control
OS_Ttimer_Run (time) Start counting current task timer Service uses system timerAllowed only in task and functions called by task
OS_Ttimer_Break () Stop and reset current task timer. Timeout flag is set Service uses system timerAllowed only in task and functions called by task
OS_Ttimer_Wait () Wait until current task timer overflows Service uses system timerAllowed only in taskSwitches context
OS_Ttimer_Delay (delay) Delay, using current task timer (same as OS_Delay) Service uses system timerAllowed only in taskSwitches context
Checking
_OST_TTIMER
OS_Ttimer_Get
() Get current task timer's remaining time Service uses system timerAllowed only in task and functions called by task
bool
OS_Ttimer_Check
() Check if current task timer has overflowed Service uses system timerAllowed only in task and functions called by task
bool
OS_Ttimer_IsRun
() Check if current task timer is counting Service uses system timerAllowed only in task and functions called by task
Additional
OS_Ttimer_Pause () Pause current task's timer. Overflow bit will be set Service uses system timerAllowed only in task and functions called by task
OS_Ttimer_Continue () Continue counting after pause Service uses system timerAllowed only in task and functions called by task

Static timers

Service Arguments Description Properties
Create/Delete
OS_Stimer_Alloc (var_stimer_id) Allocate static timer Service uses system timerNot allowed in interrupt
OS_Stimer_Free (stimer_id) Free static timer Service uses system timerNot allowed in interrupt
bool
OS_Stimer_Found
() Check if free static timer is available Service uses system timerNot allowed in interrupt
Control
OS_Stimer_Run (stimer_id, time) Start counting static timer Service uses system timer
OS_Stimer_Break (stimer_id) Stop and reset static timer. Timeout flag is set Service uses system timer
OS_Stimer_Wait (stimer_id) Wait until static timer overflows Service uses system timerAllowed only in taskSwitches context
OS_Stimer_Delay (stimer_id, delay) Delay current task using static timer Service uses system timerAllowed only in taskSwitches context
Checking
_OST_STIMER
OS_Stimer_Get
(stimer_id) Get static timer's remaining time Service uses system timer
bool
OS_Stimer_Check
(stimer_id) Check if static timer has overflowed Service uses system timer
bool
OS_Stimer_IsRun
(stimer_id) Check if static timer is counting Service uses system timer
Additional
OS_Stimer_Pause (stimer_id) Pause timer. Overflow bit will be set Service uses system timer
OS_Stimer_Continue (stimer_id) Continue counting after pause Service uses system timer

Queue of timers

Service Arguments Description Properties
Creating/Deleting
OS_Qtimer_Create (qtimer) Add timer to queue of active timers Service uses system timerNot allowed in interrupt
OS_Qtimer_Delete (qtimer) Delete timer from queue of active timers Service uses system timerNot allowed in interrupt
Control
OS_Qtimer_Run (qtimer, newtime) Start counting with given newtime. Timeout flag is cleared Service uses system timer
OS_Qtimer_Break (qtimer) Stop timer and delete it from queue. Timeout flag is set Service uses system timer
OS_Qtimer_Wait (qtimer) Wait for timer to overflow Service uses system timerAllowed only in taskSwitches context
OS_Qtimer_Delay (qtimer, delay) Delay current task using timer Service uses system timerAllowed only in taskSwitches context
Checking
_OST_QTIMER
OS_Qtimer_Get
(qtimer) Get queued timer's remaining time Service uses system timer
bool
OS_Qtimer_Check
(qtimer) Check if timer has overflowed Service uses system timer
bool
OS_Qtimer_IsRun
(qtimer) Check if timer is counting Service uses system timer

Old style timers

Dynamic timers

Service Arguments Description Properties
Creating/Deleting
OS_Dtimer_Create (dtimer) Add dynamic timer to the list of active timers Service uses system timerNot allowed in interrupt
OS_Dtimer_Delete (dtimer) Delete dynamic timer from the list of active timers Service uses system timerNot allowed in interrupt
Control
OS_Dtimer_Run (dtimer, newtime) Start counting with given newtime. Timeout flag is cleared Service uses system timer
OS_Dtimer_Break (dtimer) Stop dynamic timer. Timeout flag is set Service uses system timer
OS_Dtimer_Wait (dtimer) Wait for dynamic timer overflow Service uses system timerAllowed only in taskSwitches context
OS_Dtimer_Delay (dtimer, delay) Delay current task using dynamic timer Service uses system timerAllowed only in taskSwitches context
Checking
_OST_DTIMER
OS_Dtimer_Get
(dtimer) Get dynamic timer's remaining time Service uses system timer
bool
OS_Dtimer_Check
(dtimer) Check if dynamic timer has overflowed Service uses system timer
bool
OS_Dtimer_IsRun
(dtimer) Check if dynamic timer is counting Service uses system timer
Additional
OS_Dtimer_Pause (dtimer) Stop/pause dynamic timer. Timeout flag remains unchanged Service uses system timer
OS_Dtimer_Continue (dtimer) Continue dynamic timer's counting after pause. Timeout flag remains unchanged Service uses system timer
OS_Dtimer_Update (dtimer, time) Re-run static timer for time time since last overflow. Timeout flag is cleared Service uses system timer
OS_Dtimer_Add (dtimer, addtime) Increase time of dynamic timer counter. Timeout flag remains unchanged Service uses system timer
bool
OS_Dtimer_IsActive
(dtimer) Check if dynamic timer is present in the list of active timers Service uses system timer
bool
OS_Dtimer_IsStopped
(dtimer) Check if dynamic timer is stopped Service uses system timer

Old style static timers (not recommended for use)

Service Arguments Description Properties
Control
OS_Oldtimer_Run8 (timer8_id, time) Start counting 8-bit timer Service uses system timer
OS_Oldtimer_Run16 (timer16_id, time) Start counting 16-bit timer Service uses system timer
OS_Oldtimer_Run24 (timer24_id, time) Start counting 24-bit timer Service uses system timer
OS_Oldtimer_Run32 (timer32_id, time) Start counting 32-bit timer Service uses system timer
OS_Oldtimer_Stop (timer_id) Stop/pause static timer. Timeout flag is set Service uses system timer
Checking
bool
OS_Oldtimer_Check
(timer_id) Check for static timer overflow Service uses system timer
Waiting
OS_Oldtimer_Wait (timer_id) Wait for static timer overflow Service uses system timerAllowed only in taskSwitches context