Example #1
0
/**
 * @fn void sim_int_clock(void)
 * Fonction appelée à chaque tick (= handler de SIGALRM)
 */
void sim_int_clock() {
  struct callo *p1;
  int courant;      /* processus en cours d'exécution */
  

   if(verbose) {
    printf("TICK\n");
    fflush(stdout); 
    /* affichage du vecteur de callout */
    /*   printTab(); */
   } 
  
  /* augmentation du nombre de ticks utilisés par le processus */
  courant = GetElecProc();
  Tproc[courant].p_tick++;
  
  /* test pour la commutation */
  if(!--nbtick) {
    nbtick=Quantum;
    commut(NULL);
  }
  
  /* decrementer la premiere entree */
  MASK_ALRM;
  if (v.ve_callout[0].c_func != 0) {
    p1 = &(v.ve_callout[0]);
    while(p1->c_time<=0 && p1->c_func!=0)
      p1++;
    p1->c_time--;
  }
  
  /* restart va-t-elle être appelée */
  if((v.ve_callout[0].c_func!=0) && (v.ve_callout[0].c_time<=0))
    restart_flag |= CALLOUT;
  
  UNMASK_ALRM;
  
  /* printf("*** MAJ ***\n"); */
  /*   printTab();  */
  
  /* s'il y a de CALLOUT à traiter */
  if(restart_flag & CALLOUT) {
    /*     printf("CALLOUT\n"); */
    fflush(stdout);
    /* s'il n'y a pas de CALLOUT en traitement */
    if(!(restart_flag & RESTART_EXECUTION)) {
      /*       printf("RESTART\n"); */
      fflush(stdout);
      restart_flag &= ~CALLOUT;
      restart_flag |= RESTART_EXECUTION;
      restart();
      restart_flag &= ~RESTART_EXECUTION;
    } else {
      /*       printf("NO RESTART\n"); */
      fflush(stdout);
    }
  } else 
    ;/*     printf("pas de restart\n"); */
}
Example #2
0
int main()
{
	static char line[65536];
	char *p;
	int i, t;

	for (i = 0; i <= 255; i++)
		sprintf(fmt[i], "%c", i);

	for (i = '0'; i <= '9'; i++)
		sprintf(fmt[i], "$%c", i);

	for (t = 0; gets(line);) {
		if (t++ != 0)
			printf("\n");

		memset(use, 0, sizeof(use));

		for (top = 0, p = line; *p; p++) {
			if (isalpha(*p))
				stack[top++] = *p;
			else if (*p == '+' || *p == '*')
				commut((*p == '+') ? 'A' : 'M');
			else if (*p == '-')
				sub();
			else if (*p == '/')
				div();
			else if (*p == '@')
				neg();
		}

		if (top > 0 && stack[top - 1] != 0) {
			printf("L %s\n", fmt[stack[top - 1]]);
		}
	}

	return 0;
}