scheduler.e


/*************************************************************************
*                                                                        *
*   Export: scheduler.e                                                  *
*                                                                        *
*   realizzato dal Gruppo 17 di Lab2 Anno Accademico 1995/96             *
*                                                                        *
*   Lorenzo     Claudio       Valerio    Riccardo    Emiliano            *
*   Coronati    Lanconelli    Paolini    Solmi       Trentini            *
*                                                                        *
**************************************************************************/
#ifndef _SCHEDULER_E
#define _SCHEDULER_E

#include "thrqueue.e"
#include "procqueue.e"

#define DISPATCH()  LDST(sts)
#define SAVESTATE()    MOVBCK(sts, &run_thread->t_s, sizeof(state_t))
#define NEWSTATE()  (sts = &run_thread->t_s)
#define WAITSTATE()    (run_thread == &wait_thread)

extern void schedule();

#define ACCOUNT() \
{\
    STCK(&time_now);\
    time_left -= time_now - last_start;\
}

#define LOADTIMER() \
{\
    STCK(&last_start);\
    load_time = next_clock - last_start;\
    if (time_left < load_time)\
        load_time = time_left;\
    if (load_time < 1)\
        load_time = 1;\
    LDIT(&load_time);\
}

#define wakeupProc(thread) \
{ \
    if ((thread)->t_process->p_readyqueue == NULL) \
        insRdyQueue((thread)->t_process); \
    (thread)->t_waitfrom = NOBODY; \
    outThread(&(thread)->t_process->p_waitqueue, thread); \
    insertThread(&(thread)->t_process->p_readyqueue, thread); \
}

#define sleepProc(waitfrom) \
{ \
    outThread(&run_proc->p_readyqueue, run_thread); \
    insertThread(&run_proc->p_waitqueue, run_thread); \
    run_thread->t_waitfrom = waitfrom; \
    if (run_proc->p_readyqueue == NULL) \
        remRdyQueue(); \
    ACCOUNT(); \
}

#endif


[INDICE CODICE]