Exemple #1
0
TCB* TCB_create(int tid, ucontext_t* context, State state, int tipo, int tiquetes) {
    TCB* t = (TCB*) malloc(sizeof (TCB));
    if (t == NULL) {
        return NULL;
    } else {
        t->thread_id = tid;
        t->context = context;
        t->state = state;
        t->tiquetes = tiquetes;
        t->tipo = tipo;        
        t->waiting_for_me = TCB_list_create();
        return t;
    }
}
Exemple #2
0
int Init_scheduler()
{
	ready_threads = TCB_queue_create();
	all_threads = TCB_list_create();
	
	if(ready_threads == NULL || all_threads == NULL)
	{
		return ERROR;
	}
	else
	{
		tid_counter = 0;
		thread_counter = 0;

		return NO_ERROR;
	}
}