Exemple #1
0
void cpupool_put(struct cpupool *pool)
{
    if ( !atomic_dec_and_test(&pool->refcnt) )
        return;
    scheduler_free(pool->sched);
    free_cpupool_struct(pool);
}
Exemple #2
0
int		find_action(fds client, char *s)
{
  bool		(*schedule)(fds, _time, bool (*)(fds, char*), void *);
  t_client	*info;
  t_module	*module;
  t_mod_func	*functions;

  if (!client || !s || !(info = client->trick) ||
      !(module = info->_m) || !(functions = module->functions))
    return (false);
  while (functions && (*functions).action)
    {
      if (parse_cmp(s, (*functions).command) && (*functions).action)
	{
	  schedule = (void*)((*functions).relative ?
		      scheduler_relative : scheduler_action);
	  if ((*functions).delay <= 0.0)
	    return (((int (*)(fds, char*))(*functions).action)(client, s));
	  else
	    schedule(client, (*functions).delay, (*functions).action, s);
	  scheduler_free(client);
	  return (-1);
	}
      functions = &functions[1];
    }
  return (false);
}
void scheduler_init()
{
    if (global_scheduler != NULL)
    {
        scheduler_free(global_scheduler);
    }

    scheduler_t* scheduler = (scheduler_t*) malloc(sizeof(scheduler_t));

    scheduler->processes = (list_t*) malloc(sizeof(list_t));
    init_list(scheduler->processes);

    scheduler->currentProcess = NULL;
    scheduler->algorithm = SCHEDULING_ALGORITHM;

    global_scheduler = scheduler;
}
Exemple #4
0
void scheduler_init()
{
	task_list = NULL;
	num_tasks = 0;
	task_executing = 0;
	for(uint8_t i=0; i<MAX_NUM_SCHEDULED_TASKS; i++) scheduler_free(&task_storage_arr[i]);
	ATOMIC_BLOCK(ATOMIC_RESTORESTATE)  // Disable interrupts during initialization
	{
		// Set up real-time clock
		rtc_epoch = 0;
		CLK.RTCCTRL = CLK_RTCSRC_RCOSC_gc | CLK_RTCEN_bm;
		RTC.INTCTRL = RTC_OVFINTLVL_HI_gc;		// High level overflow interrupt to increment the epoch counter
		while (RTC.STATUS & RTC_SYNCBUSY_bm);
		RTC.PER = 0xFFFF;
		while (RTC.STATUS & RTC_SYNCBUSY_bm);
		RTC.CTRL = RTC_PRESCALER_DIV1_gc;
		while (RTC.STATUS & RTC_SYNCBUSY_bm);
		RTC.CNT = 0;
	}
}