Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

about task stack initialize ?

how to initiaze the task stack when creating a task

need help

hope anybody could relay

thanks

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hi soin :

    I have read the function OSTaskStkInit in os_cpu_c.c, but i can't unstand some

    code

    1: stk = frame_pointer - 13;

    2: stk[12] = (INT32U)task; /* task address (ra) */

    3: stk[11] = (INT32U) pdata; /* first register argument (r4) */

    4:#if OS_THREAD_SAFE_NEWLIB

    stk[10] = (INT32U) local_impure_ptr; /* value of _impure_ptr for this thread */# endif /* OS_THREAD_SAFE_NEWLIB */

    5: stk[0] = ((INT32U)&OSStartTsk) + 4;/* exception return address (ea) */

    i undstand these codes simulate the complier's action.

    in line 1: why 13 , only initialize 4 of 13 at most, stk[9]...stk[1] is for what ?

    in line 5:why need initialize ea