예제 #1
0
int FIFO() 
{
	struct sched_param param;
	param.sched_priority = 98;
	sched_setscheduler(0, SCHED_FIFO, & param);
	int i;
	int N;
	scanf("%d", &N);
	DATA* scheduler = (DATA*)malloc(N * sizeof(DATA));
	readFile(N, scheduler);
	qsort(scheduler, N, sizeof(DATA), cmp);
	int clock = 0;
	int Index = 0;
	int nextforfork = 0;
	while (Index < N) {
		waitLoop(scheduler, N, nextforfork, Index, &clock);
		executeFork(scheduler, &nextforfork, clock, N);
		
		if (scheduler[Index].flag) {
			gettime(&scheduler[Index].time[0]);
			scheduler[Index].flag = 0;
		}

		assign(scheduler, N, nextforfork, &Index, &clock);
	}

	for (i = 0; i < N; i++) {
		print_result(scheduler[i].pid, scheduler[i].time);
	}
	free(scheduler);
	return 0;
}
int main(int argc, char *argv[]) {

	/* parse commandline returns filename index in argv */
	/* create floorplan data structure					*/
	gfp=fpCreate(argv[commandlineParse(argc,argv)]);

	if (gPostScript	) gGUI 		= 1 ;	/* enable gui if post script required		*/
	if (!gGUI		) gVerbose	= 1 ;	/* enable verbose if if gui is not enabled	*/

	/* change random seed into current time */
	srandom(time(NULL));

	if (gGUI) {

		/*  calculating world and drawing dimentions							*/
		gWorldStep=MIN((880/((gfp->ny)*2)),(1000/((gfp->nx)+1))); /* grid step	*/
		gWorldX   =((gfp->nx)+1)*gWorldStep+240; /* world X dimension 			*/
		gWorldY   =(gfp->ny)*2*gWorldStep+180  ; /* world Y dimension 			*/	

		/* initialize display with WHITE 1000x1000 background */
		init_graphics((char*)"Simulated-Annealing Cell-Based Placement Tool", WHITE, NULL);
		init_world (0.,0.,gWorldX,gWorldY);

		/* Create new buttons */
		create_button ((char*)"Window"    , (char*)"---1"      , NULL     ); /* Separator				*/
		create_button ((char*)"---1"      , (char*)"Enable  PS", enablePS ); /* enable PS				*/
		create_button ((char*)"Enable  PS", (char*)"Disable PS", disablePS); /* disable PS				*/
		create_button ((char*)"Disable PS", (char*)"Run 1"     , run1     ); /* refresh every 1    temp	*/
		create_button ((char*)"Run 1"     , (char*)"Run 10"    , run10    ); /* refresh every 10   temp	*/
 		create_button ((char*)"Run 10"    , (char*)"Run 100"   , run100   ); /* refresh every 100  temp	*/
		create_button ((char*)"Run 100"   , (char*)"Run 1000"  , run1000  ); /* refresh every 1000 temp	*/
		create_button ((char*)"Run 1000"  , (char*)"Run All"   , runAll   ); /* refresh at end only		*/
	}

	/* invoke simulated-annealing placement with designated parameters */
	fpAnneal(gfp
			,(gMoveTemp*(gfp->cellsN)^(4/3))
			,gInitTemp*(gfp->bbox)
			,gCoolRate
			,gFreezeTemp/(gfp->bbox/gfp->netsN)
	);

	/* finished! wait still until 'Exit" is pressed */
	if (gGUI)
		while(1) waitLoop();

	/* free database */
	fpDelete(gfp);


	return 1;
}
예제 #3
0
파일: launch.c 프로젝트: wavs/ocre
/**
 * This function starts the extraction process with
 * the display option.
 * @param infos Informations about the launch process.
 */
void launchProgramWithDisplay(t_launch_infos *infos)
{
  SDL_Surface *screen;

  screen = NULL;
  if (infos->inFile != NULL && infos->outFile != NULL)
    {
      if (is_bmp(infos->inFile))
	{
	  InitSDL(screen,1);
	  /* Process */
	  waitLoop();
	  SDL_Quit();
	}
      else
	{
	  help("extract");
	  wfree(infos);
	  exit(EXIT_SUCCESS);
	}
    }
}
/***********************************************  main  ***********************************************
 * arguments: infile             : contains florplan details                                          *
 *           -help       (or -h) : print command usage help                                           *
 *           -verbose    (or -v) : enables verbose logging mode                                       *
 *           -postscript (or -p) : enables PostScript plotting                                        *
 *           -stepping   (or -s) : choose stepping mode, should be followed by one of the following:  *
 *                                 wave        (or w) : shows wave expansion (default)                *
 *                                 destination (or d) : shows routing of each destination             *
 *                                 net         (or n) : shows routing of each net                     *
 *                                 routeall    (or r) : shows final routing result                    *
 ******************************************************************************************************/
int main(int argc, char *argv[]) {

	/* arguments parsing */
	int argi; /* arguments index */
	int fileNameArgInd=-1; /* file name argument index */
	char psm,sm,tbm;
	for(argi=1;argi<argc;argi++) { /* check all argument */
		if (argv[argi][0]=='-') { /* switch argument */
			switch (tolower(argv[argi][1])) { /* consider first letter */

				/* help */
				case 'h':	printf("Lee-Moore Shortest Path Maze Router\n");
							printf("Usage:\n");
							printf("\tmaze [OPTIONS] INFILE\n");
							printf("Options:\n");
							printf("\t-help       (also -h): print this message\n");
							printf("\t-verbose    (also -v): verbose logging\n");
							printf("\t-postscript (also -p): generate PostScript every step\n");
							printf("\t-traceback  (also -t): traceback mode, followed by one of the following\n");
							printf("\t\tminturn     (also m): avoid turns, try to keep same direction (default)\n");
							printf("\t\tdirect      (also d): use direct paths toward source\n");
							printf("\t-stepping   (also -s): stepping mode, followed by one of the following\n");
							printf("\t\twave        (also w): wave expansion (default)\n");
							printf("\t\tdestination (also d): route one destination at once\n");
							printf("\t\tnet         (also n): route one net at once\n");
							printf("\t\trouteall    (also n): route all nets at once\n");
							printf("\tinfile syntax:\n");
							printf("\t\t<FLOORPLAN COORDINATES>\n");
							printf("\t\t<BLOCKAGES#>\n");
							printf("\t\t<BLOCKAGE 1 COORDINATE>\n");
							printf("\t\t<BLOCKAGE 2 COORDINATE>\n");
							printf("\t\t...\n");
							printf("\t\t<BLOCKAGE b COORDINATE>\n");
							printf("\t\t<NETS#>\n");
							printf("\t\t<NET 1 TARGETS#> <DEST. 1 COORD.> ... <DEST. t1 COORD.>\n");
							printf("\t\t...\n");
							printf("\t\t<NET 2 TARGETS#> <DEST. 1 COORD.> ... <DEST. t2 COORD.>\n");
							printf("\t\t<NET n TARGETS#> <DEST. 1 COORD.> ... <DEST. tm COORD.>\n");
							printf("Examples:\n");
							printf("\tmaze a.infile (using default options)\n");
							printf("\tmaze a.infile -verbose -postscript -stepping destination\n");
							printf("\tmaze a.infile -v -p -s d (same as above)\n");
							printf("Report bugs to <*****@*****.**>\n");
							return(1);

				/* verbose */
				case 'v':	verbose=1;			/* set verbose */
							break;

				/* PostScript mode */
				case 'p':	psEnable=1;			/* enable ps creation */
							break;

				/* stepping mode */
				case 's':	argi++;												/* next argument */
							if (argi>=argc) sm = 'X';							/* if index is out of range, exit */
								else sm = toupper(argv[argi][0]);
							if ((sm!='W')&&(sm!='D')&&(sm!='N')&&(sm!='R')) {	/* consider first letter */
								printf("-E- stepping modes are: wave, destination, net, routeall! Exiting...\n");
								exit(-1);
							} else steppingMode=sm;
							break;

				/* traceback mode */
				case 't':	argi++;												/* next argument */
							if (argi>=argc) tbm = 'X';							/* if index is out of range, exit */
								else tbm = toupper(argv[argi][0]);
							if ((tbm!='M')&&(tbm!='D')) {						/* consider first letter */
								printf("-E- traceback modes are: minturn, direct! Exiting...\n");
								exit(-1);
							} else tracebackMode=tbm;
							break;

				/* unknown argument */
				default :	printf("-E- unknown argument %s\n",argv[argi]);
							exit(-1);
			} /* switch */
		} else fileNameArgInd = argi; /* file name argument index */
	}

	/* check if infile is supplied */
	if (fileNameArgInd<0) {printf(" -E- infile should be supplied\n"); exit(-1);}

	/* parse input file into floorplan database */
	gfp = fpInfileParse(argv[fileNameArgInd]);

	/* initialize display with WHITE 1000x1000 background */
	init_graphics((char*)"Lee-Moore Shortest Path Maze Router", WHITE, NULL);
	init_world (0.,0.,1000.,1000.);

	/* Create new buttons */
	create_button ((char*)"Window"    , (char*)"---1"      , NULL        ); /* Separator              */
	create_button ((char*)"---1"      , (char*)"Wave Mode" , waveModeFunc); /* Show wave expansion    */
	create_button ((char*)"Wave Mode" , (char*)"Dest. Mode", destModeFunc); /* route each destination */
	create_button ((char*)"Dest. Mode", (char*)"Wire Mode" , wireModeFunc); /* route each wire        */
	create_button ((char*)"Wire Mode" , (char*)"Route All" , routeAllFunc); /* route all at once      */
 
	/* update global message and wait for 'Proceed' to proceed */
	strcpy(glabel,"Initial floorplan. Choose stepping mode then press 'Proceed' to make one step.");
	waitLoop();
	if (psEnable) postscript(drawScreen);

	/* route all pins in floorplan */
	fpRouteAll(gfp);

	/* finished! wait still until 'Exit" is pressed */
	while(1) waitLoop();

	/* free database */
	fpDelete(gfp);

}