예제 #1
0
파일: skyc.c 프로젝트: bitursa/maos
/**
   The main(). It parses the command line, setup the parms, ask the scheduler
   for signal to proceed, and then starts skysim to do sky coverage.
 */
int main(int argc, const char *argv[]){
    dirstart=mygetcwd();
    char *scmd=argv2str(argc, argv, " ");
    ARG_S* arg=parse_args(argc,argv);
    /*In detach mode send to background and disable drawing*/
    if(arg->detach){
	daemonize();
    }else{
	redirect();
    }
    info2("%s\n", scmd);
    info2("Output folder is '%s'. %d threads\n",arg->dirout, arg->nthread);
    skyc_version();
    /*register signal handler */
    register_signal_handler(skyc_signal_handler);
    /*
      Ask job scheduler for permission to proceed. If no CPUs are available,
      will block until ones are available.  if arg->force==1, will run
      immediately.
    */
    scheduler_start(scmd,arg->nthread,0,!arg->force);
    /*setting up parameters before asking scheduler to check for any errors. */
    dirsetup=stradd("setup",NULL);
    PARMS_S * parms=setup_parms(arg);
    if(parms->skyc.dbg){
	mymkdir("%s",dirsetup);
    }
    if(!arg->force){
	info2("Waiting start signal from the scheduler ...\n");
	/*Failed to wait. fall back to own checking.*/
	int count=0;
	while(scheduler_wait()&& count<60){
	    warning_time("failed to get reply from scheduler. retry\n");
	    sleep(10);
	    count++;
	    scheduler_start(scmd,arg->nthread,0,!arg->force);
	}
	if(count>=60){
	    warning_time("fall back to own checker\n");
	    wait_cpu(arg->nthread);
	}
    }
    info2("Simulation started at %s in %s.\n",myasctime(),myhostname());
    free(scmd);
    free(arg->dirout);
    free(arg);
    THREAD_POOL_INIT(parms->skyc.nthread);
    /*Loads the main software*/
    OMPTASK_SINGLE skysim(parms);
    free_parms(parms);
    free(dirsetup);
    free(dirstart);
    rename_file(0);
    scheduler_finish(0);
    info2("End:\t%.2f MiB\n",get_job_mem()/1024.);
    info2("Simulation finished at %s in %s.\n",myasctime(),myhostname());
    return 0;
}
예제 #2
0
int main(int argc, char* argv[])
{
	schd = create_scheduler();
	initialize_scheduler(schd, NULL);

	session_1 = create_session();
	initialize_session(session_1, "222.214.218.237", 6601, "1299880", 0);
	set_session_index(session_1, 0);
	add_session(schd, session_1);

	session_2 = create_session();
	initialize_session(session_2, "222.214.218.237", 6601, "1299880", 1);
	set_session_index(session_2, 1);
	add_session(schd, session_2);

	set_surface_mode(schd->surface, mode_2);

	scheduler_start(schd);
	session_start(session_1);
	session_start(session_2);

	scheduler_wait(schd);

	session_stop(session_1);
	session_stop(session_2);
	destroy_session(session_1);
	destroy_session(session_2);

	return 0;
}
예제 #3
0
int mote_main(void) {
   board_init();
   scheduler_init();
   openwsn_init();
   scheduler_start();
   return 0; // this line should never be reached
}
예제 #4
0
void main(void) {
   //configuring
   P1OUT |=  0x04;                               // set P1.2 for debug
   P4DIR  |= 0x20;                               // P4.5 as output (for debug)
   
   gina_init();
   scheduler_init();
   leds_init();
   
   if (*(&eui64+3)==0x09) {                      // this is a GINA board (not a basestation)
      gyro_init();
      large_range_accel_init();
      magnetometer_init();
      sensitive_accel_temperature_init();
   }
   
   radio_init();
   timer_init();
   
   P1OUT &= ~0x04;                               // clear P1.2 for debug
   
   //check sensor configuration is right
   gyro_get_config();
   large_range_accel_get_config();
   magnetometer_get_config();
   sensitive_accel_temperature_get_config();

   //scheduler_push_task(ID_TASK_APPLICATION);
   
   scheduler_register_application_task(&task_application_imu_radio, 0, FALSE);

   scheduler_start();
}
int mote_main(OpenMote* self) {
 board_init(self);
 scheduler_init(self);
 openwsn_init(self);
 scheduler_start(self);
   return 0; // this line should never be reached
}
예제 #6
0
int mote_main(void) {
   board_init();
   scheduler_init();
   openstack_init();
   if (idmanager_getMyID(ADDR_64B)->addr_64b[7]==0xbb) {
      idmanager_setIsDAGroot(TRUE);
   }
   scheduler_start();
   return 0; // this line should never be reached
}
예제 #7
0
// The kernel main function. Initialize everything and start the kernel
// debugger. The two arguments are the physical address of the Multiboot info
// structure and the bootloader magic number respectively.
void
init()
{
    int r;

    // Initialize the console first to print messages during the initialization
    cons_init();

    kprintf("Argentum Operating System\n");

    arch_init();

    kmem_cache_init();
    kmem_cache_sizes_init();

    vm_init();
    process_init();
    thread_init();
    ipc_init();
    scheduler_init();
    sync_init();
    clock_init();

    if ((r = process_create_system(system_main, NULL)) < 0)
        kprintf("Cannot create system process: %s\n", strerror(-r));

    if (module_start) {
        Boot_image *image = (Boot_image *) module_start;
    
        if(image->magic != 0x12345678)
            panic("invalid bootimage");

        for (unsigned i = 0; i < image->length; i++) {
            uint8_t *binary = (uint8_t *) image + image->headers[i].offset;
            size_t size = image->headers[i].length;

            if (binary < module_start || binary >= module_end)
                panic("invalid bootimage");
            if ((binary + size) <= module_start || (binary + size) > module_end)
                panic("invalid bootimage");

            r = process_create((uint8_t *) image + image->headers[i].offset,
                    image->headers[i].length, PROCESS_TYPE_USER, NULL);
            if (r < 0)
                panic("Cannot create process: %s", strerror(-r));
        }

    }

    scheduler_start();

    for (;;) {
        kdb_main(NULL);
    }
}
예제 #8
0
void main(void) {
   //configuring
   P1OUT |=  0x04;                               // set P1.2 for debug
   P4DIR  |= 0x20;                               // P4.5 as output (for debug)
   
   gina_init();
   scheduler_init();
   leds_init();
   
   if (*(&eui64+3)==0x09) {                      // this is a GINA board (not a basestation)
      magnetometer_init();
   }
   
   radio_init();
   timer_init();
   
   P1OUT &= ~0x04;                               // clear P1.2 for debug
   
   //check sensor configuration is right
   magnetometer_get_config();

   //scheduler_push_task(ID_TASK_APPLICATION);
   
   //initialize variables
   timer_period = 0x033333; //set the timer frequency to 80Hz
   
   for (int c=0;c<9;c++)
   {
     delay[c] = 0;
     out[c] = 0;
   }

   alpha[0]=	0.423466145992279;
   alpha[1]=	0.359764546155930;
   alpha[2]=	0.134587764739990;
   alpha[3]=	0.445259362459183;
   alpha[4]=	0.134587764739990;
   alpha[5]=	0.400678455829620;
   alpha[6]=	0.134587764739990;
   alpha[7]=	0.160087645053864;
   alpha[8]=	0.134587764739990;
   
   //FSM variable initialization
   threshold = 0.1096;
   state = NOCAR; //initial state
   FSMcounter = 0;
   maxCount = 10; //change?
   minCount = 2;
   seenCar=0;
   
   scheduler_register_application_task(&task_application_intersection, 410, TRUE);

   scheduler_start();
}
int mote_main(void) {
   
   // initialize
   board_init();
   scheduler_init();
   openstack_init();
   
   // indicate
   
   // start
   scheduler_start();
   return 0; // this line should never be reached
}
예제 #10
0
파일: start.c 프로젝트: ozra/ponyc
int pony_start(bool library)
{
  if(!os_socket_init())
    return -1;

  if(!scheduler_start(library))
    return -1;

  if(library)
    return 0;

  return _atomic_load(&exit_code);
}
예제 #11
0
int main(void) {
   //configuring
   P1OUT |=  0x04;                               // set P1.2 for debug
   
   gina_init();
   scheduler_init();
   button_init();
   //openwsn_init();
   P1OUT &= ~0x04;                               // clear P1.2 for debug
   
   radio_init();

   radio_rxOn(DEFAULTCHANNEL);

   scheduler_start();
}
예제 #12
0
static ERL_NIF_TERM
nif_scheduler_start(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    state_ptr state = (state_ptr) enif_priv_data(env);
    
    if(state->initilised == 0 ) 
    {
        return enif_make_tuple2(env, 
            enif_make_atom(env, "state_error"), 
            enif_make_atom(env, "scheduler_not_inited"));
    }
    
    SchedulerDriverStatus status = scheduler_start( state->scheduler_state );

    return get_return_value_from_status(env, status);
}
int main(void)
{
        I2C_init(I2C_SPEED);                 //init i2c master for 100k
        init_time_sd();
        vSemaphoreCreateBinary( event_signal ); // Create the semaphore
        xSemaphoreTake(event_signal, 0);        // Take semaphore after creating it.
        scheduler_add_task(new terminalTask(PRIORITY_HIGH));
        TaskHandle_t test1 = NULL;
        xTaskCreate((void(*)(void *))read_from_slave, "i2c_receive_task", 1024, NULL, PRIORITY_HIGH, &test1);
        eint3_enable_port2(0,eint_rising_edge,data_avail_isr);   //register for rising edge interrupt
        scheduler_add_task(new send_CAN_data(PRIORITY_MEDIUM));
        scheduler_add_task(new send_mailbox_config(PRIORITY_MEDIUM));
        scheduler_add_task(new sendTrigTask()); //Task for getting the sensor data
        scheduler_start(); ///< This shouldn't return
        return -1;
}
예제 #14
0
파일: exp.c 프로젝트: oc224/BB
//handle ctrl +c intterupt
int main(int argc,char* argv[]){

	int hh,mm,ss;
	char *fname;
	struct tm start_time;
	time_t now;
	time(&now);
	if (argc>2){
		sscanf(argv[1],"%d:%d:%d",&hh,&mm,&ss);
		start_time.tm_hour=hh;
		start_time.tm_min=mm;
		start_time.tm_sec=ss;
	}else{
		start_time=*localtime(&now);
		start_time.tm_sec+=5;
	}
	if (argc>2){
		fname=strdup(argv[2]);
	}else{
		fname=DEFAULT_SCRIPT;
	}


	printf("script file : %s\n",fname);
	printf("start time : %2d:%2d:%2d\n ",start_time.tm_hour,start_time.tm_min,start_time.tm_sec);
	if (system_cfg_read()==FAIL)	return FAIL;
	system_cfg_show();
	amodem_open();
	if (scheduler_init()==FAIL) return FAIL;
	if (scheduler_read(fname)==FAIL) return FAIL;
	scheduler_start(start_time.tm_hour,start_time.tm_min,start_time.tm_sec,'a');


	while(1){
		sleep(1);
	}
	amodem_close();
	return 0;
}
예제 #15
0
파일: main.cpp 프로젝트: mariuz/haiku
extern "C" int
_start(kernel_args *bootKernelArgs, int currentCPU)
{
	if (bootKernelArgs->kernel_args_size != sizeof(kernel_args)
		|| bootKernelArgs->version != CURRENT_KERNEL_ARGS_VERSION) {
		// This is something we cannot handle right now - release kernels
		// should always be able to handle the kernel_args of earlier
		// released kernels.
		debug_early_boot_message("Version mismatch between boot loader and "
			"kernel!\n");
		return -1;
	}

	smp_set_num_cpus(bootKernelArgs->num_cpus);

	// wait for all the cpus to get here
	smp_cpu_rendezvous(&sCpuRendezvous, currentCPU);

	// the passed in kernel args are in a non-allocated range of memory
	if (currentCPU == 0)
		memcpy(&sKernelArgs, bootKernelArgs, sizeof(kernel_args));

	smp_cpu_rendezvous(&sCpuRendezvous2, currentCPU);

	// do any pre-booting cpu config
	cpu_preboot_init_percpu(&sKernelArgs, currentCPU);
	thread_preboot_init_percpu(&sKernelArgs, currentCPU);

	// if we're not a boot cpu, spin here until someone wakes us up
	if (smp_trap_non_boot_cpus(currentCPU, &sCpuRendezvous3)) {
		// init platform
		arch_platform_init(&sKernelArgs);

		// setup debug output
		debug_init(&sKernelArgs);
		set_dprintf_enabled(true);
		dprintf("Welcome to kernel debugger output!\n");
		dprintf("Haiku revision: %lu\n", get_haiku_revision());

		// init modules
		TRACE("init CPU\n");
		cpu_init(&sKernelArgs);
		cpu_init_percpu(&sKernelArgs, currentCPU);
		TRACE("init interrupts\n");
		int_init(&sKernelArgs);

		TRACE("init VM\n");
		vm_init(&sKernelArgs);
			// Before vm_init_post_sem() is called, we have to make sure that
			// the boot loader allocated region is not used anymore
		boot_item_init();
		debug_init_post_vm(&sKernelArgs);
		low_resource_manager_init();

		// now we can use the heap and create areas
		arch_platform_init_post_vm(&sKernelArgs);
		lock_debug_init();
		TRACE("init driver_settings\n");
		driver_settings_init(&sKernelArgs);
		debug_init_post_settings(&sKernelArgs);
		TRACE("init notification services\n");
		notifications_init();
		TRACE("init teams\n");
		team_init(&sKernelArgs);
		TRACE("init ELF loader\n");
		elf_init(&sKernelArgs);
		TRACE("init modules\n");
		module_init(&sKernelArgs);
		TRACE("init semaphores\n");
		haiku_sem_init(&sKernelArgs);
		TRACE("init interrupts post vm\n");
		int_init_post_vm(&sKernelArgs);
		cpu_init_post_vm(&sKernelArgs);
		commpage_init();
		TRACE("init system info\n");
		system_info_init(&sKernelArgs);

		TRACE("init SMP\n");
		smp_init(&sKernelArgs);
		TRACE("init timer\n");
		timer_init(&sKernelArgs);
		TRACE("init real time clock\n");
		rtc_init(&sKernelArgs);

		TRACE("init condition variables\n");
		condition_variable_init();

		// now we can create and use semaphores
		TRACE("init VM semaphores\n");
		vm_init_post_sem(&sKernelArgs);
		TRACE("init generic syscall\n");
		generic_syscall_init();
		smp_init_post_generic_syscalls();
		TRACE("init scheduler\n");
		scheduler_init();
		TRACE("init threads\n");
		thread_init(&sKernelArgs);
		TRACE("init kernel daemons\n");
		kernel_daemon_init();
		arch_platform_init_post_thread(&sKernelArgs);

		TRACE("init I/O interrupts\n");
		int_init_io(&sKernelArgs);
		TRACE("init VM threads\n");
		vm_init_post_thread(&sKernelArgs);
		low_resource_manager_init_post_thread();
		TRACE("init VFS\n");
		vfs_init(&sKernelArgs);
#if ENABLE_SWAP_SUPPORT
		TRACE("init swap support\n");
		swap_init();
#endif
		TRACE("init POSIX semaphores\n");
		realtime_sem_init();
		xsi_sem_init();
		xsi_msg_init();

		// Start a thread to finish initializing the rest of the system. Note,
		// it won't be scheduled before calling scheduler_start() (on any CPU).
		TRACE("spawning main2 thread\n");
		thread_id thread = spawn_kernel_thread(&main2, "main2",
			B_NORMAL_PRIORITY, NULL);
		resume_thread(thread);

		// We're ready to start the scheduler and enable interrupts on all CPUs.
		scheduler_enable_scheduling();

		// bring up the AP cpus in a lock step fashion
		TRACE("waking up AP cpus\n");
		sCpuRendezvous = sCpuRendezvous2 = 0;
		smp_wake_up_non_boot_cpus();
		smp_cpu_rendezvous(&sCpuRendezvous, 0); // wait until they're booted

		// exit the kernel startup phase (mutexes, etc work from now on out)
		TRACE("exiting kernel startup\n");
		gKernelStartup = false;

		smp_cpu_rendezvous(&sCpuRendezvous2, 0);
			// release the AP cpus to go enter the scheduler

		TRACE("starting scheduler on cpu 0 and enabling interrupts\n");
		scheduler_start();
		enable_interrupts();
	} else {
		// lets make sure we're in sync with the main cpu
		// the boot processor has probably been sending us
		// tlb sync messages all along the way, but we've
		// been ignoring them
		arch_cpu_global_TLB_invalidate();

		// this is run for each non boot processor after they've been set loose
		cpu_init_percpu(&sKernelArgs, currentCPU);
		smp_per_cpu_init(&sKernelArgs, currentCPU);

		// wait for all other AP cpus to get to this point
		smp_cpu_rendezvous(&sCpuRendezvous, currentCPU);
		smp_cpu_rendezvous(&sCpuRendezvous2, currentCPU);

		// welcome to the machine
		scheduler_start();
		enable_interrupts();
	}

#ifdef TRACE_BOOT
	// We disable interrupts for this dprintf(), since otherwise dprintf()
	// would acquires a mutex, which is something we must not do in an idle
	// thread, or otherwise the scheduler would be seriously unhappy.
	disable_interrupts();
	TRACE("main: done... begin idle loop on cpu %d\n", currentCPU);
	enable_interrupts();
#endif

	for (;;)
		arch_cpu_idle();

	return 0;
}
예제 #16
0
void max7219s_start(void) {
	scheduler_start(20);
}
예제 #17
0
int main(void)
{
    /**
     * A few basic tasks for this bare-bone system :
     *      1.  Terminal task provides gateway to interact with the board through UART terminal.
     *      2.  Remote task allows you to use remote control to interact with the board.
     *      3.  Wireless task responsible to receive, retry, and handle mesh network.
     *
     * Disable remote task if you are not using it.  Also, it needs SYS_CFG_ENABLE_TLM
     * such that it can save remote control codes to non-volatile memory.  IR remote
     * control codes can be learned by typing the "learn" terminal command.
     */

    //scheduler_add_task(new terminalTask(PRIORITY_HIGH));

    /* Consumes very little CPU, but need highest priority to handle mesh network ACKs */
    //scheduler_add_task(new wirelessTask(PRIORITY_CRITICAL));

    /* Change "#if 0" to "#if 1" to run period tasks; @see period_callbacks.cpp */
    #if 1
        scheduler_add_task(new periodicSchedulerTask());
    #endif

    /* The task for the IR receiver */
    // scheduler_add_task(new remoteTask  (PRIORITY_LOW));

    /* Your tasks should probably used PRIORITY_MEDIUM or PRIORITY_LOW because you want the terminal
     * task to always be responsive so you can poke around in case something goes wrong.
     */

    /**
     * This is a the board demonstration task that can be used to test the board.
     * This also shows you how to send a wireless packets to other boards.
     */
    #if 0
        scheduler_add_task(new example_io_demo());
    #endif

    /**
     * Change "#if 0" to "#if 1" to enable examples.
     * Try these examples one at a time.
     */
    #if 0
        scheduler_add_task(new example_task());
        scheduler_add_task(new example_alarm());
        scheduler_add_task(new example_logger_qset());
        scheduler_add_task(new example_nv_vars());
    #endif

    /**
	 * Try the rx / tx tasks together to see how they queue data to each other.
	 */
    #if 0
        scheduler_add_task(new queue_tx());
        scheduler_add_task(new queue_rx());
    #endif

    /**
     * Another example of shared handles and producer/consumer using a queue.
     * In this example, producer will produce as fast as the consumer can consume.
     */
    #if 0
        scheduler_add_task(new producer());
        scheduler_add_task(new consumer());
    #endif

    /**
     * If you have RN-XV on your board, you can connect to Wifi using this task.
     * This does two things for us:
     *   1.  The task allows us to perform HTTP web requests (@see wifiTask)
     *   2.  Terminal task can accept commands from TCP/IP through Wifly module.
     *
     * To add terminal command channel, add this at terminal.cpp :: taskEntry() function:
     * @code
     *     // Assuming Wifly is on Uart3
     *     addCommandChannel(Uart3::getInstance(), false);
     * @endcode
     */
    #if 0
        Uart3 &u3 = Uart3::getInstance();
        u3.init(WIFI_BAUD_RATE, WIFI_RXQ_SIZE, WIFI_TXQ_SIZE);
        scheduler_add_task(new wifiTask(Uart3::getInstance(), PRIORITY_LOW));
    #endif

    scheduler_start(); ///< This shouldn't return
    return 0;
}
예제 #18
0
파일: asm.c 프로젝트: virtuoso/koowaldah
void mach_running()
{
	mach_state = MACH_RUNNING;
	local_irq_enable();
	scheduler_start();
}
예제 #19
0
파일: main.c 프로젝트: bitursa/maos
/**
   This is the standard entrance routine to the program.  It first calls
   setup_parms() to setup the simulation parameters and check for possible
   errors. It then waits for starting signal from the scheduler if in batch
   mode. Finally it hands the control to maos() to start the actual simulation.

   Call maos with overriding *.conf files or embed the overriding parameters in
   the command line to override the default parameters, e.g.

   <p><code>maos base.conf save.setup=1 'powfs.phystep=[0 100 100]'</code><p>

   Any duplicate parameters will override the pervious specified value. The
   configure file nfiraos.conf will be loaded as the master .conf unless a -c
   switch is used with another .conf file. For scao simulations, call maos with
   -c switch and the right base .conf file.
   
   <p><code>maos -c scao_ngs.conf override.conf</code><p>

   for scao NGS simulations 

   <p><code>maos -c scao_lgs.conf override.conf</code><p>

   for scao LGS simulations.  With -c switch, nfiraos.conf will not be read,
   instead scao_ngs.conf or scao_lgs.conf are read as the master config file.
   Do not specify any parameter that are not understood by the code, otherwise
   maos will complain and exit to prevent accidental mistakes.
       
   Generally you link the maos executable into a folder that is in your PATH
   evironment or into the folder where you run simulations.

   Other optional parameters:
   \verbatim
   -d          do detach from console and not exit when logged out
   -s 2 -s 4   set seeds to [2 4]
   -n 4        launch 4 threads.
   -f          To disable job scheduler and force proceed
   \endverbatim
   In detached mode, drawing is automatically disabled.
   \callgraph
*/
int main(int argc, const char *argv[]){
    char *scmd=argv2str(argc,argv," ");
    ARG_T* arg=parse_args(argc,argv);/*does chdir */
    if(arg->detach){
	daemonize();
    }else{
	redirect();
    }
    /*Launch the scheduler if it is not running and report about our process */
    int ngpu;
#if USE_CUDA
    ngpu=arg->ngpu;
    if(!ngpu) ngpu=0xFFFFFF;
#else
    ngpu=0;
#endif
    scheduler_start(scmd,NTHREAD,ngpu,!arg->force);
    info2("%s\n", scmd);
    info2("Output folder is '%s'. %d threads\n",arg->dirout, NTHREAD);
    maos_version();
    /*setting up parameters before asking scheduler to check for any errors. */
    PARMS_T *parms=setup_parms(arg->conf, arg->confcmd, arg->override);
    free(arg->conf); arg->conf=0;
    if(arg->confcmd){
	remove(arg->confcmd); free(arg->confcmd); arg->confcmd=0;
    }
    info2("After setup_parms:\t %.2f MiB\n",get_job_mem()/1024.);
    /*register signal handler */
    register_signal_handler(maos_signal_handler);
 
    if(!arg->force){
	/*
	  Ask job scheduler for permission to proceed. If no CPUs are
	  available, will block until ones are available.
	  if arg->force==1, will run immediately.
	*/
	info2("Waiting start signal from the scheduler ...\n");
	int count=0;
	while(scheduler_wait()&& count<60){
	    /*Failed to wait. fall back to own checking.*/
	    warning_time("failed to get reply from scheduler. retry\n");
	    sleep(10);
	    count++;
	    scheduler_start(scmd,NTHREAD,ngpu,!arg->force);
	}
	if(count>=60){
	    warning_time("fall back to own checker\n");
	    wait_cpu(NTHREAD);
	}
    }
    thread_new((thread_fun)scheduler_listen, maos_daemon);
    setup_parms_gpu(parms, arg->gpus, arg->ngpu);
    if(arg->server){
	while(maos_server_fd<0){
	    warning("Waiting for fd\n");
	    sleep(1);
	}
	maos_server(parms);
	EXIT;
    }
    free(scmd);
    free(arg->dirout);
    free(arg->gpus);
    free(arg);

    /*do not use prallel single in maos(). It causes blas to run single threaded
     * during preparation. Selective enable parallel for certain setup functions
     * that doesn't use blas*/
    maos(parms);
    rename_file(0);
    scheduler_finish(0);
    return 0;
}