Esempio n. 1
0
int main(){

	Task* tasks = NULL;
	int num;
	num = ReadFile(&tasks);
	if (num == -1){
		printf("There was error to read tasks. Please check your input file and it's format.\n");
		return 1;
	}
	Scheduler("rate_monotonic.txt",tasks,num,RMSCompare,0,NULL);
	Scheduler("deadline_monotonic.txt",tasks,num,DMSCompare,0,NULL);
	Scheduler("earliest_deadline_first.txt",tasks,num,DMSCompare,1,EDFCompare);
	Scheduler("least_slack_time.txt",tasks,num,StaLSTCompare,1,LSTCompare);
	free(tasks);
	return 0;
}
Esempio n. 2
0
void TimerISR() {
   	//just return if running PID is -1 (not any valid PID)
	
	if(running_pid == -1){
		cons_printf("PANIC MESSAGE: RUNNING PID = -1\n");
		return;
	
	}else{
		//in PCB, upcount both runtime and total_runtime of running process

		pcb[running_pid].runtime = pcb[running_pid].runtime+1;
		pcb[running_pid].total_runtime = pcb[running_pid].total_runtime+1;
	
		if(pcb[running_pid].runtime== TIME_LIMIT){ // If runtime has reached TIME_LIMIT
			// Reset runtime
			// Change the state to READY
			// queue to ready_q
			// Set pid to -1

			pcb[running_pid].runtime = 0;
			pcb[running_pid].state = READY;
			EnQ(running_pid, &ready_q);
			running_pid = -1;
			Scheduler();
		}	
	}
}
Esempio n. 3
0
File: OS.c Progetto: tach4455/EE345M
// ******** OS_Suspend ************
// suspend execution of currently running thread
// scheduler will choose another thread to execute
// Can be used to implement cooperative multitasking
// Same function as OS_Sleep(0)
// input:  none
// output: none
void OS_Suspend(void) {

  long curPriority;
  unsigned long curTimeSlice;
  volatile int i;

  OS_DisableInterrupts();

  // Determines NextPt
  Scheduler();

  // Get priority of next thread and calculate timeslice
  curPriority = (*NextPt).priority;
  curTimeSlice = calcTimeSlice(curPriority);

  // Sets next systick period, does not rest counting
  SysTickPeriodSet(curTimeSlice);

  // Write to register forces systick to reset counting
  NVIC_ST_CURRENT_R = 0;

  IntPendSet(FAULT_PENDSV);
  OS_EnableInterrupts();

  return;
}
void Kernel(tf_t *tf_p) // kernel begins its control upon/after interrupt
{
   int pid;

   pcbs[ cur_pid ].tf_p = tf_p; // save for cur_pid which may change

   switch( tf_p->intr_id )
   {
      case TIMER_INTR:
         TimerISR();
         break;
      case IRQ7_INTR:
         IRQ7ISR(); // service parallel printer port event
         break;
      case GETPID_INTR:
         tf_p->eax = cur_pid;
         break;
      case SLEEP_INTR:
         SleepISR();
         break;
      case SPAWN_INTR:
         pid = DeQ( &avail_q ); // get pid and put in ebx can be in Kernel()
         pcbs[ cur_pid ].tf_p->ebx = pid; // child PID, could be -1
         if( pid == -1 ) break; // no more process
         SpawnISR(pid, (func_ptr_t) pcbs[ cur_pid ].tf_p->eax);
         break;
      case SEMINIT_INTR:
         SemInitISR();
         break;
      case SEMWAIT_INTR:
         SemWaitISR(tf_p->eax);
         break;
      case SEMPOST_INTR:
         SemPostISR(tf_p->eax);
         break;
      case MSGSND_INTR:
         MsgSndISR();
         break;
      case MSGRCV_INTR:
         MsgRcvISR();
         break;
      case IRQ3_INTR:	
      case IRQ4_INTR:
         IRQ34ISR();	
         break;
      case FORK_INTR:
         pid = DeQ( &avail_q );
         ForkISR(pid);
         pcbs[ cur_pid ].tf_p->ebx = pid;
         break;
      case WAIT_INTR: //cons_printf("Wait Intr\n");
         WaitISR(); 
         break;
      case EXIT_INTR: //cons_printf("Exit Intr\n");
         ExitISR();
         break;
   }
   Scheduler();                  // find same/new process to run
   Loader(pcbs[ cur_pid ].tf_p); // load it to run
} // Kernel()
Esempio n. 5
0
//------------------------------------------------------------------------------
void OS::Kernel::ForceWakeUpProcess(TProcess& p)
{
    TCritSec cs;

    p.Timeout = 0;
    SetProcessReady(p.Priority);
    Scheduler();
}
Esempio n. 6
0
actionType choixAction() {
      // on arrète l'intérruption quand on choisi une action
    actionType TacheChoisie;
      
      TacheChoisie= Scheduler(getGrandRobot());//ActionPossible[indiceTache].action[indiceAction];
      
	return(TacheChoisie);
}
Esempio n. 7
0
/*
 * Select from tty and network...
 */
void
telnet(char *user)
{
    connections++;
    sys_telnet_init();

    if (pledge("stdio rpath tty", NULL) == -1) {
	perror("pledge");
	exit(1);
    }

    if (telnetport) {
	send_do(TELOPT_SGA, 1);
	send_will(TELOPT_TTYPE, 1);
	send_will(TELOPT_NAWS, 1);
	send_will(TELOPT_TSPEED, 1);
	send_will(TELOPT_LFLOW, 1);
	send_will(TELOPT_LINEMODE, 1);
	send_will(TELOPT_NEW_ENVIRON, 1);
	send_do(TELOPT_STATUS, 1);
	if (env_getvalue("DISPLAY", 0))
	    send_will(TELOPT_XDISPLOC, 1);
	if (binary)
	    tel_enter_binary(binary);
    }

    for (;;) {
	int schedValue;

	while ((schedValue = Scheduler(0)) != 0) {
	    if (schedValue == -1) {
		setcommandmode();
		return;
	    }
	}

	if (Scheduler(1) == -1) {
	    setcommandmode();
	    return;
	}
    }
}
Esempio n. 8
0
void MainProcess::TimeOut()
{
	

	//Remove currently running process from the front of the list and put it in the back
	readyList[currentlyRunning->getPriority()].pop_front();
	currentlyRunning->setStatus(READY);
	readyList[currentlyRunning->getPriority()].push_back(currentlyRunning);

	Scheduler();

}
Esempio n. 9
0
void do_V(int s)
{
	SemaphoreList[s].count++;
	if (SemaphoreList[s].count <= 0) {
		PCB* p = SemaphoreList[s].next;
		if (p != 0) {
			SemaphoreList[s].next = p->semanext;
			p->status = READY;
			Scheduler();
		}
	}
}
Esempio n. 10
0
void Switch() {
/*	if(ControlRequests!=0) {
		char String[16];
		IntToString(ControlRequests, String);
		Break(String);
	} */
        IntsOff();
	ExchangeRegs();
	ControlRequests++;
        GetStackPointerASM(_OldSP);
	SaveIndexes();
	Scheduler(OldSP);
}
Esempio n. 11
0
int
telnet_spin(void)
{
    int ret = 0;

    scheduler_lockout_tty = 1;
    if (Scheduler(0) == -1)
	ret = 1;
    scheduler_lockout_tty = 0;

    return ret;

}
Esempio n. 12
0
/**
	Main del cliente
*/
int main(int argc, char *argv[])
{
	if(argc != 7){
		printf("Usage: -n <N-threads> -u <url> -p <port>\n");
		return 1;
	}

	char *ptr, *host, path[100], *dns;
	dns = argv[4];
	ptr = strstr(dns, "/");
	strcpy(path, ptr);
	host = strtok(dns, "/"); //truncate the argument to a PATH and DNS name
	archivo = path;
	ip = dns;
	port= argv[6];
	num_threads = atoi(argv[2]);

	int creardor,cerrar;
	//pthread_t thread_id[num_threads];
	//#######################################################################
	contador_t = 0;
	join = 0;
	Head = Current = NULL;        /* initialize pointers  */

	if (setjmp(MAIN) == 0)        /* initialize scheduler */   
        	Scheduler();
   	//#######################################################################
	//creando hilos
	printf(" Accediendo ...\n");
	for(creardor=0; creardor < num_threads; creardor++){
		printf("Conexión: %d\n",creardor);
		MY_THREAD_CREATE(llamada, NULL);
		sleep(1);
	}
	
	//########################################################################
	if(!join)
		longjmp(SCHEDULER,1);         /* start scheduler      */
	//########################################################################
	//waits all threads to finish
/**
	for(cerrar=0; cerrar < num_threads; cerrar++) {
		pthread_join( thread_id[cerrar], NULL);
	}
*/
	MY_THREAD_JOIN();

	printf("Listo !!\n");

	return 0;
}
Esempio n. 13
0
void Kernel(tf_t *tf_p) // kernel directly enters here when interrupt occurs
{
	// Save "tf_p" to pcbs[cur_pid].tf_p for future resume of process runtime
	pcbs[cur_pid].tf_p = tf_p;

	// tf_p->intr_id tells what intr made CPU get here, pushed in entry.S
	switch(tf_p->intr_id)
	{
		case TIMER_INTR:
			TimerISR(); // this must include dismissal of timer interrupt
			break;
		case IRQ7_INTR:
			IRQ7ISR();
			break;
		case SLEEP_INTR:
			SleepISR(tf_p->eax);
			break;
		case GETPID_INTR:
			tf_p->eax = cur_pid;
			break;
		case SPAWN_INTR:
			if (EmptyQ(&avail_q)) {
				cons_printf("No more available PIDs!\n");
				tf_p->ebx = -1;
			}
			else {
				tf_p->ebx = DeQ(&avail_q);
				SpawnISR((int) tf_p->ebx, (func_ptr_t) tf_p->eax);
			}
			break;
		case SEMINIT_INTR:
			tf_p->ebx = SemInitISR(tf_p->eax);
			break;
		case SEMWAIT_INTR:
			SemWaitISR(tf_p->eax);
			break;
		case SEMPOST_INTR:
			SemPostISR(tf_p->eax);
			break;
		case MSGSND_INTR:
			MsgSndISR();
			break;
		case MSGRCV_INTR:
			MsgRcvISR();
			break;
	}

	Scheduler();                // select a process to run
	Loader(pcbs[cur_pid].tf_p); // run the process selected
}
Esempio n. 14
0
void _InterruptService() {
        register short i;
        ExchangeRegs();
        GetStackPointerASM(_UserSP);
        SaveIndexes();
	if(ControlRequests<0) Halt("NEGATIVE CONTROLREQUESTS");
        if(!IsMultitasking()) Halt("INTERRUPT IN KERNEL MODE");
	ControlRequests++;
        Tick();
        for(i=0; i<InterruptVectorCount; i++) {
                (InterruptVector[i])();
        }
        Scheduler(UserSP);
        Halt("OUT OF REACH");
}
Esempio n. 15
0
void do_P(int s)
{
	SemaphoreList[s].count--;
	if (SemaphoreList[s].count < 0) {
		pcblist[crtid].status = BLOCKED;
		PCB* p = SemaphoreList[s].next;
		if (p == 0) SemaphoreList[s].next = &pcblist[crtid];
		else {
			while (p->semanext != 0) p = p->semanext;
			p->semanext = &pcblist[crtid];
		}
		pcblist[crtid].semanext = 0;
		Scheduler();
	}
}
Esempio n. 16
0
void MainProcess::Destroy(str PID)
{
	//Check for process existence
	std::vector<str>::iterator findIt = std::find(nameList.begin(), nameList.end(), PID);

	if (findIt == nameList.end()){
		std::cout << "error ";
		ss << "error ";

		return;
	}

	//Remove from name list
	nameList.erase(findIt);

	PCB* temp;

	//Search the ready list for the PCB with the specified PID
	for (int i = 1; i < 3; i++){
		//for (PCB* p : readyList[i])
		for (std::list<PCB*>::iterator it = readyList[i].begin(); it != readyList[i].end(); it++)		
		{
			if ((*it)->getPID() == PID){
				temp = *it;
				readyList[i].erase(it);
				KillTree(temp);
				
				Scheduler();
				return;
			}
		}
	}


	temp = TreeSearch(PID, &initProcess);

	
	if (temp->getPID() != PID){
		std::cout << "error ";
		ss << "error ";
		return;

	}
	
	KillTree(temp);
	//Scheduler();
	return;
}
Esempio n. 17
0
void MainProcess::Create(str name, int p)
{

	std::vector<str>::iterator it = std::find(nameList.begin(), nameList.end(), name);

	if (it != nameList.end()){
		std::cout << "error ";
		ss << "error ";

		return;
	}

	if (p > 2){
		std::cout << "error ";
		ss << "error ";

		return;
	}

	else{

		//Add the new process name to the list of process names
		nameList.push_back(name);

		//Create a reference to a new process
		PCB* newProcess = new PCB(name, p);

		//Set the back pointer to the ready list
		newProcess->setBackPtr(readyList);

		//Set the parent pointer to the parent process
		newProcess->setParent(currentlyRunning);

		//Add it to the process tree
		currentlyRunning->children.push_back(newProcess);

		//Add the new process to the ready list
		newProcess->setStatus(READY);
		readyList[newProcess->getPriority()].push_back(newProcess);

		//Call the scheduler
		Scheduler();

	}



}
Esempio n. 18
0
File: main.c Progetto: suond/csc159
void KernelMain(TF_t *TF_ptr) {
   
  
   int new_pid;
   
	pcb[running_pid].TF_ptr = TF_ptr;
	switch(TF_ptr ->intr_id) {
	    case(TIMER_INTR):
	       TimerISR();
		OS_clock++;
		checkWait();
		outportb(0x20, 0x60); //stops the timer pic with a code
	       break;
		case(SLEEP_INTR):
		   Sleep_ISR(TF_ptr->eax);
		   break;
		case(GETPID_INTR):
		   TF_ptr->eax = running_pid;
		   break;
		case(STARTPROC_INTR):
		   new_pid = DeQ(&free_q);
		   StartProcISR(new_pid,TF_ptr->eax);
		   break;
		case(SEMWAIT_INTR):
		   SemWaitISR(TF_ptr->eax);
	           break;
		case(SEMPOST_INTR):
		   SemPostISR(TF_ptr->eax);
		   break; 
		case(SEMGET_INTR):
		   SemGetISR(TF_ptr->eax);
	  	   break;
		case(MSGSND_INTR):
		    MsgSndISR(TF_ptr->eax);
		    break;
		case(MSGRCV_INTR):
		    MsgRcvISR(TF_ptr->eax); 
		    break;
	    default:
		cons_printf("Panic: unknown intr ID (%d)!\n",TF_ptr->intr_id);
		breakpoint();
	}		
   
   Scheduler();  
   LoadRun(pcb[running_pid].TF_ptr); 
}
void Kernel(tf_t *tf_p) // kernel begins its control upon/after interrupt
{
   int pid, sid;

   pcbs[cur_pid].tf_p = tf_p; // save for cur_pid which may change

   switch(tf_p->intr_id)
   {
      case TIMER_INTR:
         TimerISR(); // service the simulated timer interrupt
         break;
      case GETPID_INTR:
         tf_p->eax = cur_pid;
         break;
      case SLEEP_INTR:
         SleepISR();
         break;
      case SPAWN_INTR:
         if(EmptyQ(&avail_q)) {
            cons_printf("No more processes\n");
            tf_p->eax = -1;
         }
         else {
            pid = DeQ(&avail_q);
            pcbs[pid].state = READY;
            SpawnISR(pid, (func_ptr_t) tf_p->eax);
            tf_p->eax = pid;
         }
         break;
      case SEMINIT_INTR:
         sid = SemInitISR(tf_p->eax);
         tf_p->eax = sid;
         break;   
      case SEMWAIT_INTR:
         SemWaitISR();
         break;
      case SEMPOST_INTR:
         SemPostISR();
         break;      
   }

   
   Scheduler();                // find same/new process to run
   Loader(pcbs[cur_pid].tf_p); // load it to run
} // Kernel()
Esempio n. 20
0
void Kernel(tf_t *tf_p) // kernel directly enters here when interrupt occurs
{
   // Save "tf_p" to pcbs[cur_pid].tf_p for future resume of process runtime
   pcbs[cur_pid].tf_p = tf_p;
   
   // tf_p->intr_id tells what intr made CPU get here, pushed in entry.S
   switch(tf_p->intr_id)
   {
      case TIMER_INTR:
         TimerISR(); // this must include dismissal of timer interrupt
         break;
      case SLEEP_INTR:
            SleepISR(tf_p->eax);
            break;
       case GETPID_INTR:
            tf_p->eax = cur_pid;
            break;
   }

   // still handles other keyboard-generated simulated events
   if(cons_kbhit()) // check if a key was pressed (returns non zero)
   {
      char key = cons_getchar(); // get the pressed key

      switch(key) // see if it's one of the following for service
      {
         case 'n':
            if(EmptyQ(&avail_q))
               cons_printf("No more available PIDs!\n");
            else
            {
               SpawnISR(DeQ(&avail_q), SimpleProc);
            }
            break;
         case 'k': KillISR(); break; // non-functional in phase 2
         case 's': ShowStatusISR(); break;
         case 'b': breakpoint(); break; // this stops when run in GDB mode
         case 'q': exit(0);
      } // switch(key)
   } // if(cons_kbhit())

   Scheduler();                // select a process to run
   Loader(pcbs[cur_pid].tf_p); // run the process selected
}
Esempio n. 21
0
void MainProcess::Reset()
{

	for (int i = 0; initProcess.children.size(); i++){

		KillTree(initProcess.children[i]);

	}


	nameList.erase(nameList.begin(), nameList.end());

	std::cout << std::endl;
	ss << std::endl;

	Scheduler();
	

}
Esempio n. 22
0
  void System::Problem_generate_geometry(const int param)
  {

    const double dt_max = 1.0/64;
    scheduler = Scheduler(dt_max);

    t_end      = 2.5;
    dt_restart = 1.0/64;
    dt_snap    = 1.0/16;

    dt_restart = std::max(dt_restart, dt_max);
    dt_snap    = std::max(dt_snap,    dt_max);

#if 1
    dt_snap = dt_max;
#endif


    const int global_n = NX*NY*NZ;
    std::vector<int> n_per_element(numElements, 0);

    for (int i = 0; i < global_n; i++)
      n_per_element[i % numElements]++;

    local_n = n_per_element[thisIndex];

    ptcl_list.clear();
    ptcl_list.reserve(local_n);

    Rand48 rnd;
    rnd.srand(123 + 123*thisIndex);
    for (int i = 0; i < local_n; i++)
    {
      vec3 pos;
      pos.x = global_domain.get_rmin().x + rnd.drand() * global_domain_size.x;
      pos.y = global_domain.get_rmin().y + rnd.drand() * global_domain_size.y;
      pos.z = global_domain.get_rmin().z + rnd.drand() * global_domain_size.z;
      ptcl_list.push_back(Particle(i, thisIndex, pos));
    }

    generateGeometry_nRelax = 2;
  }
int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_LIB_TEXT ("Refcounted_Auto_Ptr_Test"));


  // =========================================================================
  // The following test uses the ACE_Refcounted_Auto_Ptr in a single
  // thread of control, hence we use the ACE_Null_Mutex

  ACE_DEBUG ((LM_DEBUG,
              ACE_LIB_TEXT ("(%t) performing synchronous test...\n")));

  Printer *printer1;
  ACE_NEW_RETURN (printer1,
                  Printer ("I am printer 1"),
                  -1);
  {
    ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r(printer1);
    ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r1(r);
    ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r2(r);
    ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r3(r);
    ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r4(r);
    ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r5 = r2;
    ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r6 = r1;
  }
  ACE_DEBUG ((LM_DEBUG,
              ACE_LIB_TEXT ("(%t) Printer instance count is %d, expecting 0\n"),
              Printer::instance_count_));
  ACE_ASSERT (Printer::instance_count_ == 0);

#if defined (ACE_HAS_THREADS)

  // =========================================================================
  // The following test uses the ACE_Refcounted_Auto_Ptr in multiple
  // threads of control.

  ACE_DEBUG ((LM_DEBUG,
              ACE_LIB_TEXT ("(%t) performing asynchronous test...\n")));

  Scheduler *scheduler_ptr;

  // Create active objects..
  ACE_NEW_RETURN (scheduler_ptr,
                  Scheduler (),
                  -1);

  auto_ptr<Scheduler> scheduler(scheduler_ptr);

  ACE_ASSERT (scheduler->open () != -1);

  {
    ACE_NEW_RETURN (printer1,
                    Printer ("I am printer 2"),
                    -1);

    Printer_var r (printer1);

    for (int i = 0; i < n_loops; i++)
      // Spawn off the methods, which run in a separate thread as
      // active object invocations.
      scheduler->print (r);
  }

  // Close things down.
  scheduler->end ();

  scheduler->wait ();

  ACE_DEBUG ((LM_DEBUG,
              ACE_LIB_TEXT ("(%t) Printer instance count is %d, expecting 0\n"),
              Printer::instance_count_));
  ACE_ASSERT (Printer::instance_count_ == 0);

#endif /* ACE_HAS_THREADS */
  ACE_END_TEST;

  return 0;
}
Esempio n. 24
0
/*
 * Select from tty and network...
 */
void
my_telnet(char *user)
{
    int printed_encrypt = 0;

    sys_telnet_init();

#if	defined(AUTHENTICATION) || defined(ENCRYPTION)
    {
	static char local_host[256] = { 0 };

	if (!local_host[0]) {
		/* XXX - should be k_gethostname? */
		gethostname(local_host, sizeof(local_host));
		local_host[sizeof(local_host)-1] = 0;
	}
	auth_encrypt_init(local_host, hostname, "TELNET", 0);
	auth_encrypt_user(user);
    }
#endif
    if (telnetport) {
#if	defined(AUTHENTICATION)
	if (autologin)
		send_will(TELOPT_AUTHENTICATION, 1);
#endif
#if	defined(ENCRYPTION)
	send_do(TELOPT_ENCRYPT, 1);
	send_will(TELOPT_ENCRYPT, 1);
#endif
	send_do(TELOPT_SGA, 1);
	send_will(TELOPT_TTYPE, 1);
	send_will(TELOPT_NAWS, 1);
	send_will(TELOPT_TSPEED, 1);
	send_will(TELOPT_LFLOW, 1);
	send_will(TELOPT_LINEMODE, 1);
	send_will(TELOPT_NEW_ENVIRON, 1);
	send_do(TELOPT_STATUS, 1);
	if (env_getvalue((unsigned char *)"DISPLAY"))
	    send_will(TELOPT_XDISPLOC, 1);
	if (binary)
	    tel_enter_binary(binary);
    }

#ifdef ENCRYPTION
    /*
     * Note: we assume a tie to the authentication option here.  This
     * is necessary so that authentication fails, we don't spin
     * forever.
     */
    if (telnetport && wantencryption) {
	time_t timeout = time(0) + 60;

	send_do(TELOPT_ENCRYPT, 1);
	send_will(TELOPT_ENCRYPT, 1);
	while (1) {
	    if (my_want_state_is_wont(TELOPT_AUTHENTICATION)) {
		if (wantencryption == -1) {
		    break;
		} else {
		    printf("\nServer refused to negotiate authentication,\n");
		    printf("which is required for encryption.\n");
		    Exit(1);
		}
	    }
	    if (auth_has_failed) {
		printf("\nAuthentication negotiation has failed,\n");
		printf("which is required for encryption.\n");
		Exit(1);
	    }
	    if (my_want_state_is_dont(TELOPT_ENCRYPT) ||
		my_want_state_is_wont(TELOPT_ENCRYPT)) {
		printf("\nServer refused to negotiate encryption.\n");
		Exit(1);
	    }
	    if (encrypt_is_encrypting())
		break;
	    if (time(0) > timeout) {
		printf("\nEncryption could not be enabled.\n");
		Exit(1);
	    }
	    if (printed_encrypt == 0) {
		    printed_encrypt = 1;
		    printf("Waiting for encryption to be negotiated...\n");
		    /*
		     * Turn on MODE_TRAPSIG and then turn off localchars
		     * so that ^C will cause telnet to exit.
		     */
		    TerminalNewMode(getconnmode()|MODE_TRAPSIG);
		    intr_waiting = 1;
	    }
	    if (intr_happened) {
		    printf("\nUser interrupt.\n");
		    Exit(1);
	    }
	    if (telnet_spin()) {
		    printf("\nServer disconnected.\n");
		    Exit(1);
	    }
		
	}
	if (printed_encrypt) {
		printf("Encryption negotiated.\n");
		intr_waiting = 0;
		setconnmode(0);
	}
    }
#endif

    for (;;) {
	int schedValue;

	while ((schedValue = Scheduler(0)) != 0) {
	    if (schedValue == -1) {
		setcommandmode();
		return;
	    }
	}

	if (Scheduler(1) == -1) {
	    setcommandmode();
	    return;
	}
    }
}
void SingleObvCalcForDyn::SchedulerEachWork(YK_ID curWorkId, YK_TM leftBound, YK_ID& splitedWorkId,YK_ID resId
									,list<WorkResInfo>& allWorkResInfoList,vector<SchdulerFlg>& schFlgList
									,vector<TestSchedulerInfo>& workPlanList,vector<AMWorkSPtr>& workList)
{
	splitedWorkId = 0;

	YK_TM leftStartTm = leftBound;								//	��ʼʱ��

	AppendWorkSPtr pAppWork = g_Application.Get<AppendWorkDao>()->GetWork(curWorkId);
	if (pAppWork.IsNULL()) return;

	AMWorkSPtr workPtr = g_Application.Get<AMMapWork>()->GetObj(curWorkId);
	if (!workPtr.ValidObj()) return;

	g_Application.Get<CMainFlow>()->SetCurAppWork(pAppWork);

	/************************************************************************/
	//	��ÿ�����Դ���1
	/************************************************************************/
	list<WorkResInfo> workResInfoList;
	CResourceMgr resourceMgr(Dir_Obverse);
	if (g_Application.Get<CMainFlow>()->GetSchMaintainFlg() && !BMaintainWork(curWorkId))
	{
		WorkResInfo workResForMT;
		workPtr.GetPlanResRelaCom(workResForMT.resRelaID, workResForMT.assistResRelaList, true);
		if(workResForMT.resRelaID.ValidObj())
			workResInfoList.push_back(workResForMT);
	}
	else
	{
		resourceMgr.GetResComb(workPtr,workResInfoList);
	}

	//����ԭ�ƻ�,�̶�������ȡ��Դ����߼�֮ǰ����������ƻ�
	workPtr.ClearSchPlan();

	CSingleObvCalcV3SPtr pCalc = GetFollower<CSingleObvCalcV3>();
	if (workResInfoList.empty() )
	{
		return;
	}

	//����������Դ���
	list<WorkResInfo>::iterator i_workResInfo = workResInfoList.begin();
	for (;i_workResInfo != workResInfoList.end();i_workResInfo++)
	{
		WorkResInfo& workResInfo = *i_workResInfo;

		if(workResInfo.resRelaID.GetRes().GetID() != resId)
		{
			continue;
		}
		SchdulerFlg schFlg;

		GetFollower<CSchTools>()->Init();

		pCalc->GetPrdTm(workPtr,workResInfo, GetFollower<CSchTools>()->m_prdTimeLen
			,schFlg.workPlanAmount);

		//�ų̼���
		if(!Scheduler( workPtr, leftStartTm, 0, workResInfo ))
		{
			//��¼������Դ����ϵ��ų̼ƻ�
			allWorkResInfoList.push_back(workResInfo);
			workPlanList.push_back(GetFollower<CSchTools>()->m_lastSucessTestSchInfo);
			workList.push_back(workPtr);
			GetFollower<CSchTools>()->m_lastSucessTestSchInfo.ClearPlan();

			schFlg.schFlg = true;
			schFlgList.push_back(schFlg);
		}
	}	
}
Esempio n. 26
0
File: main.c Progetto: mios16/CPE159
void KernelMain(TF_t *TF_ptr) 
{
	int new_pid, i, pid, len;
	char key;

	pcb[running_pid].TF_ptr = TF_ptr;	//save TF_ptr to PCB of running process
	
	switch(TF_ptr->intr_id)			//switch on TF_ptr->intr_id
	{
		case TIMER_INTR:
				TimerISR();	//call TimerISR()
				outportb(0x20, 0x60);	//dismiss timer event: send PIC with a code
				OS_clock++;
				len = sleep_q.len;

				for(i = 0; i < len; i++)
				{
					pid = DeQ(&sleep_q);
					if(OS_clock == pcb[pid].wake_time)
					{
						EnQ(pid, &ready_q);
						pcb[pid].state = READY;
					}
					else
					{
						EnQ(pid, &sleep_q);
					}	
				}
				break;
		case GETPID_INTR:
				GetPidISR();
				break;
		case SLEEP_INTR:
				SleepISR();
				break;
		default:
				cons_printf("Panic: unknown intr ID (%d)!\n", TF_ptr->intr_id);
				breakpoint();		//fallback to GDB
	}

	//same as simulated, handle keystroke simulated events (s/e/b/x, but no 't' key)
	if(cons_kbhit())
	{
		key = cons_getchar();
		switch(key)
		{
			case 's':
				new_pid = DeQ(&free_q);	//dequeue free_q for a new pid
				if (new_pid == -1)	//if the new pid (is -1) indicates no ID left
				{				
					cons_printf("Panic: no more available process ID left!\n");	//show msg on target PC			
				}
				else
				{
					StartProcISR(new_pid);	//call StartProcISR(new pid) to create new proc
				}
				break;
			case 'e':
				EndProcISR();	//call EndProcISR() to handle this event
				break;
			case 'b':
				breakpoint();	//call breakpoint(); to go into GDB
				break;
			case 'x':
				exit(0);	//just call exit(0) to quit MyOS.dli
				break;
			default :		// no keys were pressed
				break;
		}
	}
	Scheduler();				//call scheduler() to process to load/run if needed
	LoadRun(pcb[running_pid].TF_ptr);	//call LoadRun(pcb[running_pid].TF_ptr) to load/run selected proc
}
Esempio n. 27
0
/**
 * @fn int main(void)
 * @brief Fonction main du programme.
 */
int main(void) {
	// Déclaration des variables locales.
    match oldMatchStatus = OVER;            // Etat précédent duu match (pour les actions d'entrée)
	actionType choix;                  //<! Pointeur vers l'action en cours.
	positionInteger positionInitiale;       //<! Position initiale du robot sur la table
	team equipe;                            //<! Equipe actuelle.

//    propIsObstacleType test;
	pllConfig();					// Configuration de la PLL de l'horloge interne pour tourner à 40MIPS
	assignSPIO();					// Assignation des pins du dSPIC.
    
    timerSetup(5, 50);
    TMR5 = 0;
	// Initialisation du CAN
	CanInitialisation(CN_LOGIQUE);
	propulsionInitCan();
    CanDeclarationProduction(CN_LOGIQUE*0x10, &matchStatus, sizeof(matchStatus));
    CanDeclarationProduction(CN_LOGIQUE*0x10, &mesureSharp, sizeof(mesureSharp));
	ACTIVATE_CAN_INTERRUPTS = 1;
	//msTimerInit();                  // Initialisation du timer des millisecondes, n'est utilisé que pour waitXms (TODO: enlever en mêm temps que waitXms)

	while(1) {
		if (getMatchTimerFlag()) {
			matchStatus = OVER;
		}
		// Machine d'état de la logique
	switch (matchStatus) {
            case INIT:                  // Etat initial, phase précédant le match
                if (matchStatus != oldMatchStatus) {
                    oldMatchStatus = matchStatus;
                    CanEnvoiProduction(&matchStatus);
                    matchTimerInit();				// Initialisation du timer de match
                    initADC();
                    //initBLE();
                    initStepper();
                    if (EnvoiSharpActif == 1){
                        timerStart(5);
                        IEC1bits.T5IE = 1;
                    }  
                    sendPosition(positionInitiale);
                }
                if (!GOUPILLE_OTEE) {
                    matchStatus = PRE_MATCH;
                }
                break;
            case PRE_MATCH:             // Le robot attend le début du match. On peut encore choisir la couleur

                if (matchStatus != oldMatchStatus) {
                    oldMatchStatus = matchStatus;
                    CanEnvoiProduction(&matchStatus);
                }

				//if (BOUTON_EQUIPE == JAUNE) {
				//	equipe = JAUNE;
				//	positionInitiale = positionInitialeJaune;
					//ordreActions = actionsJaune;
				//} else {
					equipe = VERT;
					positionInitiale = positionInitialeVert;
				//}
				// TRANSITIONS
                   // réparer la goupille ENCORE
			//	if (GOUPILLE_OTEE) {       
                    // si la goupille est retirée, le match commence
					__delay_ms(1000);
                    StartMatchTimer();                                                      // on lance le timer de match (90s))
                    propulsionEnable();  // on active la propulsion
                   // msTimerStart();
                    
                    while(propulsionGetStatus() != STANDING);                               // on attend que l'ordre soit exécuté
					propulsionSetPosition(positionInitiale);                                // On initialise la position de la propulsion
                    while(!compareXYAlpha(propulsionGetPosition(), positionInitiale));     // on attend que l'ordre soit exécuté
                    choix = choixAction();                                                  // Sélection de la prochaine action => c'est dans cette fonction qu'il faut mettre de l'IA
					matchStatus = ONGOING;

			//	}
				break;
            case ONGOING: // Le match est lancé

                if (matchStatus != oldMatchStatus) {
                    oldMatchStatus = matchStatus;
                    CanEnvoiProduction(&matchStatus);
                }
                
                    if (getTaskRequest()){
                        setTaskRequest(0);
                        Scheduler(getPetitRobot());
                }
                infoAction = choix.ptr2Fct(choix.dest,choix.methode);
                

                
                if (canReceivedOrderFlag) {
                    canReceivedOrderFlag = 0;
                    if (canReceivedCommand == LOGI_SHARP_MESURE) {
                        EnvoiSharpActif = canReceivedData[0];
                   }
                }

                switch(infoAction.statut) {
                    case ACTION_PAS_COMMENCEE:
                    case ACTION_EN_COURS:
                        
                        // on attend la fin de l'action
                        break;
                    case ACTION_FINIE:
                    case ACTION_REMISE:
                        sendPosition(propulsionGetPosition());
                        choix = choixAction();                  // Sélection de la prochaine action => c'est dans cette fonction qu'il faut mettre de l'IA
                        break;
                    case ACTION_ERREUR:
                        matchStatus = ERROR;

                    default:
                        break;
                }
                break;
            case OVER:
                if (matchStatus != oldMatchStatus) {
                    oldMatchStatus = matchStatus;
                    CanEnvoiProduction(&matchStatus);
                    propulsionDisable();
                }
                if (!GOUPILLE_OTEE) {
                    matchStatus = INIT;
                }
                break;
            case ERROR:
                if (matchStatus != oldMatchStatus) {
                    oldMatchStatus = matchStatus;
                    CanEnvoiProduction(&matchStatus);
                }
                choix = gestionErreur(choix);
                matchStatus = ONGOING;
                break;
            default:
                matchStatus = ERROR;
                break;
        }
        
        
   }

    return 0;
}
Esempio n. 28
0
int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Bound_Ptr_Test"));


  // =========================================================================
  // The following test uses the ACE_Strong_Bound_Ptr in a single
  // thread of control, hence we use the ACE_Null_Mutex

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) performing synchronous test...\n")));

  Parent *parent1 = 0;
  ACE_NEW_RETURN (parent1,
                  Parent,
                  -1);
  ACE_Weak_Bound_Ptr<Parent, ACE_Null_Mutex> p8;
  {
    // Must get the pointer from the parent object's weak_self_ member.
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p(parent1->weak_self_);
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p1(p);
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p2(p);
    ACE_Weak_Bound_Ptr<Parent, ACE_Null_Mutex> p3(p);
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p4(p);
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p5 = p2;
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p6 = p3;
    ACE_Weak_Bound_Ptr<Parent, ACE_Null_Mutex> p7(p1);
    p8 = p2;
    p->child_->do_something ();
  }
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) Parent instance count is %d, expecting 0\n"),
              Parent::instance_count_));
  if (Parent::instance_count_ != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) parent instance count not 0...\n")),
                         -1);
    }
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) Child instance count is %d, expecting 0\n"),
              Child::instance_count_));
  if (Child::instance_count_ != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) child instance count not 0...\n")),
                         -1);
    }
  // Weak pointer should now be set to null.
  if(!p8.null ())
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) p8 not nill...\n")),
                         -1);
    }

  Printer *printer1 = 0;
  ACE_NEW_RETURN (printer1,
                  Printer ("I am printer 1"),
                  -1);
  ACE_Weak_Bound_Ptr<Printer, ACE_Null_Mutex> r9;
  {
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r(printer1);
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r1(r);
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r2(r);
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r3(r);
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r4(r);
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r5 = r2;
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r6 = r1;
    ACE_Weak_Bound_Ptr<Printer, ACE_Null_Mutex> r7(r1);
    ACE_Weak_Bound_Ptr<Printer, ACE_Null_Mutex> r8 = r2;
    r9 = r3;
    r9->print ();
  }
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) Printer instance count is %d, expecting 0\n"),
              Printer::instance_count_));
  if (Printer::instance_count_ != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) Printer instance count not 0...\n")),
                         -1);
    }
  // Weak pointer should now be set to null.
  if (!r9.null ())
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) r9 not nill...\n")),
                         -1);
    }

#if defined (ACE_HAS_THREADS)

  // =========================================================================
  // The following test uses the ACE_Strong_Bound_Ptr in multiple
  // threads of control.

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) performing asynchronous test...\n")));

  Scheduler *scheduler_ptr = 0;

  // Create active objects..
  ACE_NEW_RETURN (scheduler_ptr,
                  Scheduler (),
                  -1);

  ACE_Strong_Bound_Ptr<Scheduler, ACE_Null_Mutex> scheduler(scheduler_ptr);

  if (scheduler->open () == -1)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) Scheduler open failed...\n")),
                         -1);
    }

  {
    Printer *printer2 = 0;
    ACE_NEW_RETURN (printer2,
                    Printer ("I am printer 2"),
                    -1);

    // Ownership is transferred from the auto_ptr to the strong pointer.
    auto_ptr<Printer> a (printer2);
    Printer_var r (a);

    for (int i = 0; i < n_loops; i++)
      // Spawn off the methods, which run in a separate thread as
      // active object invocations.
      scheduler->print (r);
  }

  // Close things down.
  scheduler->end ();

  scheduler->wait ();

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) Printer instance count is %d, expecting 0\n"),
              Printer::instance_count_));
  if (Printer::instance_count_ != 0)
    return -1;

#endif /* ACE_HAS_THREADS */
  ACE_END_TEST;

  return 0;
}
Esempio n. 29
0
  void system::set_geometry(const bool init) 
  {
    const double dt_max = 1.0/64 ; //16; // 1.0/128;
    scheduler = Scheduler(dt_max);

    t_end   = 2.5;

    n_restart = 1;
    dt_restart = dt_max;

    dt_dump = dt_max / 16;
    dt_dump = dt_max ; //* 4;

    di_log = 100;

    global_n = local_n = 0;
    int nx = 16;
    int ny = 16;
    int nz = 16;

    //		nx = ny = nz = 32;

    //		nx = ny = nz = 64;

    nx = ny = 32; nz = 32;

    //		nx = ny = 32; nz = 16;
    nx = ny = 64; nz = 16;
     nx = ny = 128; nz = 16;
    // nx = ny = 256; nz = 16;


    //		nx = ny = 256;	nz = 256;


    //		nx = ny = nz = 128;

    //		eulerian = true;


#if 0
#if 1
#define __ADVECT_PULSE_TEST__
    nx = ny = 64;	nz = 16;
    dt_dump = dt_max;
    dt_restart = 1e10;
#endif
    //		nx = ny = 128;
#endif


    const double Lx = 1.0;
    const vec3 rmin(0.0);
    const vec3 rmax(Lx, (Lx/nx)*ny, (Lx/nx)*nz);
    global_domain = boundary(rmin, rmax);
    global_domain_size = global_domain.hsize() * 2.0;

    const vec3 Len3 = global_domain.hsize() * 2.0;
    pfloat<0>::set_scale(Len3.x);
    pfloat<1>::set_scale(Len3.y);
    pfloat<2>::set_scale(Len3.z);

    Distribute::int3 nt(1, 1, 1);
    switch(nproc) 
    {
      case 1: break;
      case 2: nt.x = 2; nt.y = 1; nt.z = 1; break;
      case 4: nt.x = 2; nt.y = 2; nt.z = 1; break;
      case 8: nt.x = 4; nt.y = 2; nt.z = 1; break;
      case 16: nt.x = 4; nt.y = 4; nt.z = 1; break;
      case 32: nt.x = 8; nt.y = 4; nt.z = 1; break;
      case 64: nt.x = 8; nt.y = 8; nt.z = 1; break;
      case 128: nt.x = 8; nt.y = 8; nt.z = 2; break;
      default: assert(false);
    }

    const Distribute::int3 nt_glb(nt);
    const pBoundary pglobal_domain(pfloat3(0.0), pfloat3(Len3));
    distribute_glb.set(nproc, nt, pglobal_domain);

    if (!init) return;

    if (myproc == 0) 
    {

      ptcl_local.clear();
      ptcl_local.reserve(128);

      const dvec3 dr = dvec3(Len3.x/nx, Len3.y/ny, Len3.z/nz);
      const real rmax = dr.abs() * 1.0;

      fprintf(stderr, "dr= %g %g %g \n", dr.x, dr.y, dr.z);
      fprintf(stderr, "rmin= %g %g %g \n", 
          global_domain.get_rmin().x,
          global_domain.get_rmin().y,
          global_domain.get_rmin().z);
      fprintf(stderr, "rmax= %g %g %g \n", 
          global_domain.get_rmax().x,
          global_domain.get_rmax().y,
          global_domain.get_rmax().z);

      for (int k = 0; k < nz; k++) {
        for (int j = 0; j < ny; j++) {
          for (int i = 0; i < nx; i++) {
            dvec3 pos = global_domain.get_rmin() + dvec3(i*dr.x, j*dr.y, k*dr.z) + 0.5*dr;
            const int ijk = (k*ny + j)*nx + i;
#if 0
            if (!eulerian)
            {
              const real f = 1.0e-6;
              pos += vec3(drand48()*dr.x*f, drand48()*dr.y*f, drand48()*dr.z*f);
            }
#endif


#if 1
            pos = global_domain.get_rmin() + dvec3(
                drand48()*Len3.x,
                drand48()*Len3.y,
                drand48()*Len3.z);
#else
#define _UNIFORM_MESH_
#endif
            dvec3 vel(0.0, 0.0, 0.0);
            Particle p;
            p.set_pos(pos);
            p.vel = vel;
            p.orig_vel = p.vel;
            p.boundary = 0;
            p.idx = ijk;
            p.rmax = rmax;
            ptcl_local.push_back(p);
          }
        }
      }
      local_n  = ptcl_local.size();
      global_n = local_n;

      fprintf(stderr, "  *** proc= %d : local_n= %llu  global_n= %llu \n", myproc, local_n, global_n);
    } // myproc == 0

    MPI_Bcast(&global_n,  1, MPI_INT, 0, MPI_COMM_WORLD);

    MPI_Barrier(MPI_COMM_WORLD);
    if (myproc == 0)
      fprintf(stderr, " ***  Distrubiting data \n");

    all_active = true;

    for (int k = 0; k < 5; k++)
      distribute_data(false,false,false);

#if 0
    std::vector< std::pair<int, TREAL> > rmax_list;
    local_tree.root.get_rmax(rmax_list);
    assert((int)rmax_list.size() == local_n);
    for (int i = 0; i < local_n; i++)
      ptcl[rmax_list[i].first].rmax = rmax_list[i].second;
#endif

    MPI_Barrier(MPI_COMM_WORLD);
    fprintf(stderr, " *** proc= %d : local_n= %llu  global_n= %llu \n", myproc, local_n, global_n);
    fprintf(stderr, " proc= %d  relax \n", myproc);

#ifndef _UNIFORM_MESH_
    relax_mesh(5);
#endif
    fprintf(stderr, " ---- done --- \n");
    {
      distribute_data(false, false, false);
      const double t10 = mytimer::get_wtime();
      clear_mesh(false);
      int nattempt = build_mesh_global();
      double dt10 = mytimer::get_wtime() - t10;

      double volume_loc = 0.0;
      {
        std::vector<TREAL> v(local_n);
        for (int i = 0; i < (int)local_n; i++)
          v[i] = cell_local[i].Volume;
        std::sort(v.begin(), v.end());  // sort volumes from low to high, to avoid roundoff errors
        for (int i = 0; i < (int)local_n; i++)
          volume_loc += v[i];
      }


      double dt10max;
      MPI_Allreduce(&dt10, &dt10max, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
      double volume_glob = 0.0;	
      int    nattempt_max, nattempt_min;
      MPI_Allreduce(&volume_loc, &volume_glob,  1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
      MPI_Allreduce(&nattempt,   &nattempt_max, 1, MPI_INT,    MPI_MAX, MPI_COMM_WORLD);
      MPI_Allreduce(&nattempt,   &nattempt_min, 1, MPI_INT,    MPI_MIN, MPI_COMM_WORLD);

      const double volume_exact = global_domain_size.x*global_domain_size.y*global_domain_size.z;
      if (myproc == 0)
      {
        fprintf(stderr, "first call build_mesh:[ %g  sec ::  %g cells/s/proc/thread ]\n",
            dt10max,
            global_n/nproc/dt10max);
        fprintf(stderr, "   computed_volume= %g  exact_volume= %g diff= %g [ %g ]  nattempt= %d %d \n",
            volume_glob, volume_exact, 
            volume_glob - volume_exact,	(volume_glob - volume_exact)/volume_exact,
            nattempt_min, nattempt_max);
      }
    }


    extract_ngb_from_mesh();
#if 0
    set_problem(true);
    iterate();

    MPI_Barrier(MPI_COMM_WORLD);
    MPI_Finalize();
    exit(-1);
#endif
  }
Esempio n. 30
0
static void test_scheduler(std::ostream & os) {
   test_all_scheduler(Scheduler(0,  0),  0, os);
   test_all_scheduler(Scheduler(1,  0),  0, os);
   test_all_scheduler(Scheduler(0,  1),  0, os);

   test_all_scheduler(Scheduler(1,  1),  1, os);
   test_all_scheduler(Scheduler(1,  2),  0, os);
   test_all_scheduler(Scheduler(1,  3),  0, os);
   test_all_scheduler(Scheduler(1,  4),  0, os);
   test_all_scheduler(Scheduler(1,  5),  0, os);

   test_all_scheduler(Scheduler(2,  1),  1, os);
   test_all_scheduler(Scheduler(2,  2),  1, os);
   test_all_scheduler(Scheduler(2,  3),  2, os);
   test_one_scheduler(Scheduler(2,  4), os);
   test_one_scheduler(Scheduler(2,  5), os);
   test_one_scheduler(Scheduler(2,  6), os);
   test_one_scheduler(Scheduler(2,  7), os);
   test_one_scheduler(Scheduler(2,  8), os);
   test_one_scheduler(Scheduler(2,  9), os);
   test_one_scheduler(Scheduler(2, 10), os);

   test_all_scheduler(Scheduler(3,  1),  1, os);
   test_all_scheduler(Scheduler(3,  2),  0, os);
   test_all_scheduler(Scheduler(3,  3), 12, os);
   test_all_scheduler(Scheduler(3,  4),  0, os);
   //test_one_scheduler(3,  5, os); // for now this one takes too long to run after each compile

   test_all_scheduler(Scheduler(4,  1),  1, os);
   test_all_scheduler(Scheduler(4,  2),  0, os);
   test_all_scheduler(Scheduler(4,  3),  0, os);
   test_one_scheduler(Scheduler(4,  4), os);
   test_all_scheduler(Scheduler(4,  5),  0, os);

   test_all_scheduler(Scheduler(5,  1),  1, os);
   test_all_scheduler(Scheduler(5,  2),  0, os);
   test_all_scheduler(Scheduler(5,  3),  0, os);
   test_all_scheduler(Scheduler(5,  4),  0, os);
   test_one_scheduler(Scheduler(5,  5), os);

   // Test more general cases
   test_one_scheduler(Scheduler(2, 2, 3, 0, 3), os);
}