Пример #1
0
int main( void ){

	disableWDT();// Stop watchdog timer
	initQueue();
	initScheduler();

	initButton();
	initLed();
	initComUart();

	initInfo();

	mainTask.cmdName = cmdNameMain;
	mainTask.user = main_user;
	mainTask.handler = &mainHandler;
	registerTask( &mainTask );

	setDCOCLK( DCO_1M );
	setSMCLK( SMCLK_DCO, CLK_DIV_1 );

	if( getFreeMessage( &mainMessage ) == queue_ok ){
		mainMessage->source = main_user;
		mainMessage->destination = led_user;
		mainMessage->id = MSG_ID_LED_GREEN;
		mainMessage->priority = normal_priority;
		mainMessage->event = undef_event;
		putMessage( mainMessage );
	}

	if( getFreeMessage( &mainMessage ) == queue_ok){
		mainMessage->destination = com_uart_user;
		mainMessage->source = main_user;
		mainMessage->id = MSG_ID_UART_WELCOME;
		putMessage( mainMessage );
	}

	initCli();

	enableTimerA0CCInterrupt();
	setTimerA0Mode( TAMODE_CONT );
	setTimerA0ClockSource( TA_SMCLK );
	setTimerA0Divider( TA_DIV_1 );

	__enable_interrupt();

	__bis_SR_register( 0x18 );

	//__bis_SR_register( 0x18 ); // LPM0 with interrupts enabled

	while( 1 ){};

	return 0;
}
Пример #2
0
void initRMC (int & __argc, char * * & __argv)
{

  /* Communication */
  initCommunication ();
  communicator_thread = new Communicator (& __argc, & __argv);
  addThread (communicator_thread, ll_threads);
  waitNodeInitialization ();
  initSending ();

  /* Scheduler */
  if (isScheduleNode ())
  {
    initScheduler ();
  }
}
Пример #3
0
Kernel::Kernel() {
    _ramManager = new RAMManager();
    _mmu = new MMU(this);
    _loader = new Loader(_ramManager);
	_taskManager = new TaskManager(_mmu);
	_serviceManager = new ServiceManager(_taskManager, _loader);
    _executor = new SystemCallExec(this, _taskManager);
	_handlerManager = new HandlerManager(this);
    
    _displayTaskId = -1;
	initInterruptHandler(
			_handlerManager->getIrqHandler(), 
			_handlerManager->getSwiHandler(), 
			_taskManager, _mmu);
			
	initScheduler();
}
Пример #4
0
int main (int argc, char** argv) {
	/** Parse the argument at command line. */
	optParse (argc, argv);


	if (daemonFork (appConf.dconf) == 0) {
		initGMetric (appConf.gmonConf);
		initScheduler ();
		scheduler ();
	} else {
		INFO ("Launched\n");
	}

	finalizeGMetric ();

	return 0;
}
Пример #5
0
int main() {

	int i,j;

	/* Setting up CPU0 new areas in ROM. */
	populateArea((state_t *)INT_NEWAREA,(memaddr)intHandler,0);
	populateArea((state_t *)TLB_NEWAREA,(memaddr)tlbHandler,0);
	populateArea((state_t *)PGMTRAP_NEWAREA,(memaddr)trapHandler,0);
	populateArea((state_t *)SYSBK_NEWAREA,(memaddr)sysHandler,0);

	/* Setting up CPU-n (with n >= 1) new areas in RAM, in a defined array of state_t pointers. */
	for (i = 1; i < NUM_CPU; i++)
		for (j = 0; j < 4; j++)

			switch (j) {

			case 0: populateArea(&new_old_areas[i][1],(memaddr)intHandler,i); break;
			case 1: populateArea(&new_old_areas[i][3],(memaddr)tlbHandler,i); break;
			case 2: populateArea(&new_old_areas[i][5],(memaddr)trapHandler,i); break;
			case 3: populateArea(&new_old_areas[i][7],(memaddr)sysHandler,i); break;

			}

	/* Initialization of underlaying data structures. */
	initPcbs();
	initASL();

	/* Inizialization of device semaphores. TODO */

	if ((psClock_timer = getSemd(0)) != NULL)
		psClock_timer -> s_value = 0;

	if ((terminalWrite = getSemd(1)) != NULL)
		terminalWrite -> s_value = 0;

	if ((terminalRead = getSemd(2)) != NULL)
		terminalRead -> s_value = 0;

	/* Scheduler initialization process. */
	initScheduler(i);

	return 1;
}
Пример #6
0
// FIX - too long (separate into more than one function)
// FIX - Make a function that prints out its usage (help function)
void initParameters(int argc, char ** argv){
    char * arch_filename = DEFAULT_ARCH_FILENAME;
    char * dfg_filename = DEFAULT_DFG_FILENAME;
    char * prr_filename = DEFAULT_PRR_FILENAME;
    int seed = randSeed();
    int c;

    opterr = 0;
    while((c = getopt(argc, argv, "a:b:c:d:f:g:h:m:n:o:p:r:s:t:Vvw:")) != -1){
        switch(c){
            case 'a':
                arch_filename = optarg;
                break;
                
            case 'b':
                if(strncasecmp("one-point", optarg, strlen(optarg))  == 0 || 
                    strncasecmp("one_point", optarg, strlen(optarg)) == 0 ||
                    strncasecmp("one point", optarg, strlen(optarg)) == 0 )
                    crossover_type = 1;
                else if(strncasecmp("two-point", optarg, strlen(optarg)) != 0 &&
                        strncasecmp("two_point", optarg, strlen(optarg)) != 0 &&
                        strncasecmp("two point", optarg, strlen(optarg)) != 0 ){
                    fprintf(stderr, "Unknown crossover option : %s\n", optarg);
                    exit(1);
                }
                break;
                
            case 'c':
                setCrossoverRate(atof(optarg));
                break;
                
            case 'd':
                dfg_filename = optarg;
                break;
                
            case 'f':
                setFitnessFunction(optarg);
                break;
                
            case 'g':
                MAX_NUM_GENERATIONS = atoi(optarg);
                break;
                
            case 'h':
                setSetupIndex(atoi(optarg));
                break;
                
            case 'm':
                setMutationRate(atof(optarg));
                break;
                
            case 'n':
               if(strncasecmp("random", optarg, strlen(optarg)) == 0)
                    mutation_type = 2;
                else if(strncasecmp("rotationally", optarg, strlen(optarg)) != 0){ 
                    fprintf(stderr, "Unknown mutation option : %s\n", optarg);
                    exit(1);
                }
                break;
                
            case 'p':
                setPopSize(atoi(optarg));
                break;
                
            case 'r':
                if(strncasecmp("keep-best", optarg, strlen(optarg))  == 0 ||
                    strncasecmp("keep_best", optarg, strlen(optarg)) == 0 ||
                    strncasecmp("keep best", optarg, strlen(optarg)) == 0)
                    replacement_type = 2;
                else if(strncasecmp("all", optarg, strlen(optarg)) != 0){
                    fprintf(stderr, "Unknown replacement option : %s\n", optarg);
                    exit(1);
                }
                break;

            case 's':
                if(strncasecmp("random", optarg, strlen(optarg)) == 0)
                    selection_type = 2;
                else if(strncasecmp("tournament", optarg, strlen(optarg)) != 0){ 
                    fprintf(stderr, "Unknown selection option : %s\n", optarg);
                    exit(1);
                }
                break;
                
            case 't':
                seed = atoi(optarg);
                break;
                
            case 'V':
            case 'v':
                fprintf(stdout, "Offline Scheduler version 2.0  (GA + Napoleon + rcSimulator)\n");
            #ifdef DEBUG
                fprintf(stdout, "Using the DEBUG build\n\n");
            #endif
            
            #ifdef VERBOSE
                fprintf(stdout, "Using the VERBOSE build\n\n");
            #endif
            
            #ifdef STATS
                fprintf(stdout, "Using the STATS build\n\n");
            #endif
                
                fprintf(stdout, "Please see https://github.com/Aalwattar/GA for more information\n");
                exit(0);
                
            case 'w':
                setRuntimeWeight(atof(optarg));
                break;
                
            case ':':   
                fprintf(stderr, "Option -%c requires an operand\n", optopt);
                break;
            case '?':
                fprintf(stderr, "Unrecognized option: -%c\n", optopt);

            default:
                exit(1);
        }
    }

    if(optind < argc){
        printf("Non-option argument %s\n", argv[optind]);
        exit(1);
    }
    
    // FIX - Check the return value
    seedRandGenerator(seed);
    

    if(initScheduler(arch_filename, dfg_filename, prr_filename) == EXIT_FAILURE)
        exit(1);

    
    if(POP_SIZE == 0){
        POP_SIZE = getNumNodes();
    }
    
    fprintf(stdout, "Parameters:\n");
    fprintf(stdout, "\tFitness Function = %s\n\n", getFitnessFunction());
    fprintf(stdout, "\tPopulation Size       = %d\n", POP_SIZE);
    fprintf(stdout, "\tNumber of Generations = %d\n\n", MAX_NUM_GENERATIONS);
    fprintf(stdout, "\tMutation Rate  = %.4lf\n", getMutationRate());
    fprintf(stdout, "\tCrossover Rate = %.4lf\n", getCrossoverRate());
    fprintf(stdout, "\tRuntime Weight = %.4lf\n", getRuntimeWeight());
    fprintf(stdout, "\tPower Weight   = %.4lf\n\n", 1.0 - getRuntimeWeight());
    
    if(crossover_type == 1)
        fprintf(stdout, "\tCrossover Algorithm   = One point Crossover\n");
    else
        fprintf(stdout, "\tCrossover Algorithm   = Two point Crossover\n");
    
    if(mutation_type == 1)
        fprintf(stdout, "\tMutation Algorithm    = Rotational Mutation\n");
    else
        fprintf(stdout, "\tMutation Algorithm    = Random Mutation\n");
    
    if(selection_type == 1)
        fprintf(stdout, "\tSelection Algorithm   = Tournament Selection\n");
    else
        fprintf(stdout, "\tSelection Algorithm   = Random Selection\n");
    
    if(replacement_type == 1)
        fprintf(stdout, "\tReplacement Algorithm = Replace All\n\n");
    else
        fprintf(stdout, "\tReplacement Algorithm = Keep Best\n\n");
    
    // FIX - make this dynamic
    fprintf(stdout, "\tSeed             = %d\n", seed);
    fprintf(stdout, "\tPercent seeding  = %.4lf\n", (1.0 - PERCENT_POP_RANDOM));
}