Ejemplo n.º 1
0
int main() {
 void (*execcode)()=(void *)bsdi_killcode;
 printf("[ (BSDi)*[v3.0/3.1]: system failu"
 "re, by: v9[[email protected]]. ]\n");
 printf("*** no output should be seen afte"
 "r this point.\n");
 execcode();
 printf("*** system failure failed.\n");
 exit(0);
}
Ejemplo n.º 2
0
int execute(int argc, char** argv, int /* boolean */ trace) {
  int *p = readfile(argv[trace ? 2 : 1]);         // program bytecodes: int[]
  int *s = (int*)malloc(sizeof(int)*STACKSIZE);   // stack: int[]
  int iargc = trace ? argc - 3 : argc - 2;
  int *iargs = (int*)malloc(sizeof(int)*iargc);   // program inputs: int[]
  int i;
  for (i=0; i<iargc; i++)                         // Convert commandline arguments
    iargs[i] = atoi(argv[trace ? i+3 : i+2]);
  // Measure cpu time for executing the program
  struct rusage ru1, ru2;
  getrusage(RUSAGE_SELF, &ru1);
  int res = execcode(p, s, iargs, iargc, trace);  // Execute program proper
  getrusage(RUSAGE_SELF, &ru2);
  struct timeval t1 = ru1.ru_utime, t2 = ru2.ru_utime;
  double runtime = t2.tv_sec-t1.tv_sec+(t2.tv_usec-t1.tv_usec)/1000000.0;
  printf("\nUsed %7.3f cpu seconds\n", runtime);
  return res;
}
Ejemplo n.º 3
0
int execute(int argc, char** argv, int /* boolean */ trace) {
	int *p = readfile(argv[trace ? 2 : 1]);         // program bytecodes: int[]
	int *s = (int*)malloc(sizeof(int)*STACKSIZE);   // stack: int[]
	int iargc = trace ? argc - 3 : argc - 2;
	int *iargs = (int*)malloc(sizeof(int)*iargc);   // program inputs: int[]
	int i;
	for (i = 0; i < iargc; i++)                         // Convert commandline arguments
		iargs[i] = atoi(argv[trace ? i + 3 : i + 2]);
	// Measure cpu time for executing the program

	int t1 = getUserTimeMs();
	int res = execcode(p, s, iargs, iargc, trace);  // Execute program proper
	int t2 = getUserTimeMs();
	int runtime = t2 - t1;
	printf("\nUsed %d cpu milli-seconds\n", runtime);

	return res;
}