Monday, February 24, 2014

Task Management: Create Task

① Creating Task

All the parameters from user side are passed. They are Task Start address, Stack size, Priority, stack space address if have preferred address space, as only allocation and initialization to default are performed here. Some more attributes such as Task has to be activated just with this call also passed here. Task moves from Non-existent state to Dormant state. If the task is activated inside, taks enters to Ready queue for the first time.

② ITRON implementation of cre_tsk()

ER cre_tsk(ID tskid, T_CTSK *pk_ctsk)
{
        /* Clear distinction between the system calls that can be called from non-task contexts */
        If (called from ISR)
                return E_CTX;
        Sanity check on arguments;
        Enter Critical section;
        Allocate memory for TCB and stack;
        Initialize TCB as follows;
        state = DORMANT, activated=0, lock acquired=0
        base priority=current priority=assigned by user
        stack pointer=Address of the stack space
        exception handler=NULL;
        Initialize the stack space excluding the space for context as
         in sta_tsk the initial context will be formed inside the stack space
        Exit critical section
        if the activate flag is set
                activate the task;
        return E_OK;
}

Create just takes backup of arguments and allocates resources..

No comments: