int main (void){

	init();
	pcb* first_process;
	first_process =(pcb*) rpq_dequeue();
	current_process = first_process;
	longjmp(first_process->jbdata,1);
	return EXIT_SUCCESS;
}
Example #2
0
void process_switch( )
{
    int error_code;
    //suspend 'current' process to release CPU
    PCB *next_process; //hold pointer to the next process pcb
    PCB *previous_process;
    next_process = (PCB *) rpq_dequeue( ); //pointer points to the next highest priority ready process 
    previous_process = current_process; //Setting the current process as previous process
    current_process = next_process; //Setting the current process PCB to the next process
    if( current_process->process_id != 5 || previous_process->process_id != 5)
       printf("process_switch: Context switch from %i to %i \n", previous_process->process_id, current_process->process_id);
    fflush(stdout);
    context_switch( previous_process->context, next_process->context ); //switch the context of 'previous' process to 'next' process
/*
    if (current_process->process_state== EXECUTING) {
        current_process->process_state = INTERRUPTED;
        error_code = rpq_enqueue(current_process);
    }
    else if(current_process->process_state==BLOCKED_ON_ENVELOPE) {
        error_code = blocked_on_resource_Q_enqueue(current_process);
    }
    current_process = next_process;// set 'current_process' to point to next's PCB*/

}