Ejemplo n.º 1
0
static task_t* steal_task_prio(runqueue_t* rq,int cpu){
    task_t* t=tail_slist(&rq->tasks);
    
    if (t) {
        remove_slist(&rq->tasks,t);
        t->on_rq=FALSE;
        rq->nr_runnable--;
    }
    return t;    
}
Ejemplo n.º 2
0
Archivo: sched.c Proyecto: ferreiro/C
/* Add a log register for the post simulation analysis */
static void add_log_register(task_t* task, task_state_t state, int cpu, int when, int how_long)
{
    sched_log_t* log_reg=tail_slist(&task->sched_regs);
    sched_log_t* new_reg;

    /* Do not insert empty registers */
    if (how_long==0)
        return;

    if (!log_reg || log_reg->state!=state || log_reg->cpu!=cpu ) {
        new_reg=(sched_log_t*)malloc(sizeof(sched_log_t));
        new_reg->state=state;
        new_reg->cpu=cpu;
        new_reg->when=when;
        new_reg->how_long=how_long;

        insert_slist(&task->sched_regs,new_reg);
    } else {
        /* If thread was runnable and now it's ONPROC -> Update the previous register */
        log_reg->how_long+=how_long;
    }
}