Exemplo n.º 1
0
/*---------------------------------------------------------------------------*/
void     task_idle (void)
{
    tcb_t *task ;

    printf ("Akalon: In Idle Task\n") ;

    /* We are in the Idle Task. Now let the BSP create the rest of  */
    /* the System's resources (tasks, sems, init routines, etc) by  */
    /* calling bsp_post_init(). However, interrupts should never be */
    /* enabled in bsp_post_init(). Also, note that any new task     */
    /* that's created in bsp_post_init() will not switch out the    */
    /* Idle Task because it is running at the highest priority.     */

    bsp_post_init () ;

    kernel.int_mode = NO ; /* Remove this HACK !!! <--- DO */

    /* All System Resources have now been created. Lower the Idle   */
    /* Task's priority to the lowest.                               */

    task_rm_from_q (kernel.task_idle) ;
    kernel.task_idle->priority = -1   ;
    task_add_to_q  (kernel.task_idle) ;

    /* Get the highest priority task and run it. Interrupts will be */
    /* enabled when the task is run by task_start().                */

    task = task_ready_get() ;

    if (task != kernel.task_idle)
    {
       kernel.task_idle->state = TASK_READY ;
       task_run_next (kernel.task_idle) ;
    }

    /* Interrupts were never enabled when the idle task was run. So */
    /* enable interrupts and start spinning until another task gets */
    /* into the ready state, which can happen becuase an interrupt. */
    /* If an interrupt never happens (for what ever reason), then   */
    /* to code will be stuck in the following while(1) loop.        */   

    cpu_enable_ints() ;
    while (1) 
    {
       /* Check if any task needs to be deleted */
       task_cleanup() ;
    }
    
} /* End of function task_idle() */
Exemplo n.º 2
0
/* Gets the task to ready state */
TaskState_t os_task_ready_get( uint8_t tid ) {
    os_assert( tid < nTasks );
    return task_ready_get( tid );
}