Пример #1
0
static int nodemenu_select(ClientData data, Tcl_Interp *interp,
				int argc, char *argv[])
{
    extern void	unschedule_node(int node);
    int		n, s;

    if(vflag) {
	for(n=0 ; n<argc-1 ; ++n)
	    fprintf(stderr,"%s ", argv[n]);
	fprintf(stderr,"%s\n", argv[argc-1]);
    }
    if(argc != 3) {
	interp->result	= "wrong # args";
	return TCL_ERROR;
    }
    n	= atoi(argv[1]);
    s	= atoi(argv[2]);
    if(n < 0 || n >= _NNODES || s < 0 || s >= N_NODEMENU_STRINGS) {
	interp->result	= "invalid node or menu arg";
	return TCL_ERROR;
    }

    switch (s) {
    case RE :	NP[n].runstate  = STATE_REBOOTING;
		schedule_event(EV_REBOOT, n, int64_ONE, NULLTIMER,
				NP[n].data[(int)EV_REBOOT]);
		break;
    case CR :	NP[n].runstate  = STATE_CRASHED;
		unschedule_node(n);
		break;
    case SR :	NP[n].runstate	= STATE_AUTOREBOOT;
		schedule_event(EV_REBOOT, n, int64_ONE, NULLTIMER,
				NP[n].data[(int)EV_REBOOT]);
		break;
    case P1 :
    case P6 :	NP[n].runstate	= STATE_PAUSED;
		int64_I2L(NP[n].will_resume, (s == P1 ? 10000000 : 60000000));
		schedule_event(EV_REBOOT, n, NP[n].will_resume, NULLTIMER,
				NP[n].data[(int)EV_REBOOT]);
		int64_ADD(NP[n].will_resume, TIMENOW_in_USEC,NP[n].will_resume);
		break;
    }
    draw_node_icon(FALSE,n);
    if(dflag)
	fprintf(stderr,"%s.menu -> %s\n", NP[n].nodename, menu_strings[s]);

    return TCL_OK;
}
Пример #2
0
void
_engine_schedule_clear (EngineSchedule *sched)
{
  guint i;
  
  g_return_if_fail (sched != NULL);
  g_return_if_fail (sched->secured == FALSE);
  g_return_if_fail (sched->in_pqueue == FALSE);
  
  for (i = 0; i < sched->leaf_levels; i++)
    {
      /* FIXME: each unschedule operation is a list walk, while we
       * could easily leave the rings alone and free them as a whole
       */
      while (sched->nodes[i])
	unschedule_node (sched, sched->nodes[i]->data);
      while (sched->cycles[i])
	unschedule_cycle (sched, sched->cycles[i]->data);
    }
  g_return_if_fail (sched->n_items == 0);
}