Hooks and Port API Changes

Table C-18 shows the difference in APIs used to port µC/OS-II to µC/OS-III.

Hooks and Port API
µC/OS-II (OS_CPU*.C/H)µC/OS-III (OS_CPU*.C/H)Note

OS_GET_TS();
(1)
void
OSInitHookBegin(void);
void
OSInitHook(void);

void
OSInitHookEnd(void);


void
OSTaskCreateHook(
    OS_TCB    *ptcb);
void
OSTaskCreateHook(
    OS_TCB        *p_tcb);

void
OSTaskDelHook(
    OS_TCB    *ptcb);
void
OSTaskDelHook(
    OS_TCB        *p_tcb);

void
OSTaskIdleHook(void);
void
OSIdleTaskHook(void);


void
OSTaskReturnHook(
    OS_TCB        *p_tcb);
(2)
void
OSTaskStatHook(void)
void
OSStatTaskHook(void);

void
OSTaskStkInit(
    void     (*task)(void *p_arg),
    void      *p_arg,
    OS_STK    *ptos,
    INT16U     opt);
CPU_STK *
OSTaskStkInit(
    OS_TASK_PTR    p_task,
    void          *p_arg,
    CPU_STK       *p_stk_base,
    CPU_STK      *p_stk_limit,
    CPU_STK_SIZE   size,
    OS_OPT         opt);
(3)
void
OSTaskSwHook(void)
void
OSTaskSwHook(void);

void
OSTCBInitHook(
    OS_TCB    *ptcb);

(4)
void
OSTimeTickHook(void);
void
OSTimeTickHook(void);

void
OSStartHighRdy(void);
void
OSStartHighRdy(void);
(5)
void
OSIntCtxSw(void);
void
OSIntCtxSw(void);
(5)
void
OSCtxSw(void);
void
OSCtxSw(void);
(5)

(1) µC/OS-III requires that the Board Support Package (BSP) provide a 32-bit free-running counter (from 0x00000000 to 0xFFFFFFFF and rolls back to 0x00000000 ) for the purpose of performing time measurements. When a signal is sent, or a message is posted, this counter is read and sent to the recipient. This allows the recipient to know when the message was sent. If a 32-bit free-running counter is not available, you can simulate one using a 16-bit counter but, this requires more code to keep track of overflows.

(2) µC/OS-III is able to terminate a task that returns. Recall that tasks should not return since they should be either implemented as an infinite loop, or deleted if implemented as run once.

(3) The code for OSTaskStkInit() must be changed slightly in µC/OS-III since several arguments passed to this function are different than in µC/OS-II. Instead of passing the top-of-stack as in µC/OS-II, OSTaskStkInit() is passed the base address of the task stack, as well as the size of the stack.

(4) This function is not needed in µC/OS-III.

(5) These functions are a part of os_cpu_a.asm, and should only require name changes for the following variables:

µC/OS-II variable changes from …… to this in µC/OS-III
OSIntNesting
OSIntNestingCtr
OSTCBCur
OSTCBCurPtr
OSTCBHighRdy
OSTCBHighRdyPtr