Ejemplo n.º 1
0
int __init hello_init(void)
{
	RTIME sampling;

	rt_printk(KERN_INFO "TESTE - *************************** INICIO *******************************\n");

	rt_task_init(&Task_1, signalIchi, 0, 3000, 0, 0, NULL);
	rt_task_init(&Task_2,   signalNi, 0, 3000, 0, 0, NULL);
	rt_task_init(&Task_3,  signalSan, 0, 3000, 0, 0, NULL);

	sampling = start_rt_timer(nano2count(TICK));

	rt_sem_init(&rMutex, 1);

	rt_task_make_periodic(&Task_1, rt_get_time() + sampling * 16, sampling * 16);
	rt_task_make_periodic(&Task_2, rt_get_time() + sampling * 18, sampling * 18);
	rt_task_make_periodic(&Task_3, rt_get_time() + sampling * 30, sampling * 30);

	rt_change_prio(&Task_1, 2);
	rt_change_prio(&Task_2, 1);
	rt_change_prio(&Task_3, 3);

	rt_printk(KERN_INFO "Init module function\n");
	return 0;
}
Ejemplo n.º 2
0
int init_module(void)
{
	int i;
	DBG_PRINT_INIT;
	if (rt_task_init(&start_task, start_task_code, 0, 10000, 10, 0, 0) != 0) {
		printk("Could not start init task\n");
	}
	if (rt_mbx_init(&mbx_in, NUM_TASKS*8) || rt_mbx_init(&mbx_out, NUM_TASKS*8)) {
		printk("could not create message queue\n");
		return 1;
	}
	for (i = 0; i < NUM_TASKS; ++i) {
		rt_sem_init(&sems[i], 0);
		if (rt_task_init(&tasks[i], task_code, i, 3000, NUM_TASKS - i, 0, 0) != 0) {
			printk("rt_task_ipc_init failed\n");
			return 1;
		}
	}     
#ifdef ONE_SHOT
	rt_set_oneshot_mode();
#endif
	start_rt_timer_ns(10000000);
	checkt = rdtsc();
	checkj = jiffies;
	rt_task_resume(&start_task);
	for (i = 0; i < NUM_TASKS; ++i) {
		rt_task_resume(&tasks[i]);
	}     
	return 0;
}
Ejemplo n.º 3
0
Archivo: kern.c Proyecto: ArcEye/RTAI
int init_module(void)
{
	start_rt_timer(0);
	rt_task_init(&rtai_sig_task, tsk_sig_fun, 0, STKSZ, 0, 0, 0);
	rt_task_resume(&rtai_sig_task);
	rt_task_init(&sig_task, sig_fun, 0, STKSZ, 0, 0, sighdl);
	rt_task_resume(&sig_task);
	return 0;
}
Ejemplo n.º 4
0
int init_module(void)
{
	rt_bits_init(&bits, 0xFFFF0000);
	rt_task_init(&task0, fun0, 0, STACK_SIZE, 0, 0, 0);
	rt_task_init(&task1, fun1, 0, STACK_SIZE, 0, 0, 0);
	rt_task_init(&task, fun, 0, STACK_SIZE, 0, 0, 0);
	rt_set_oneshot_mode();
	start_rt_timer(nano2count(SLEEP_TIME));
	rt_task_resume(&task0);
	rt_task_resume(&task1);
	rt_task_resume(&task);
	return 0;
}
Ejemplo n.º 5
0
Archivo: mbx.c Proyecto: cjecho/RTAI
int init_module(void)
{
	rt_typed_mbx_init(&smbx, 5, MBX_TYPE); //5
	rt_typed_mbx_init(&rmbx[0], 1, MBX_TYPE); //1
	rt_typed_mbx_init(&rmbx[1], 3, MBX_TYPE); //3
	rt_task_init(&btask, bfun, 0, STACK_SIZE, 0, 0, 0);
	rt_task_init(&mtask[0], mfun, 0, STACK_SIZE, 1, 0, 0);
	rt_task_init(&mtask[1], mfun, 1, STACK_SIZE, 1, 0, 0);
	rt_set_oneshot_mode();
	start_rt_timer(nano2count(SLEEP_TIME));
	rt_task_resume(&btask);
	rt_task_resume(&mtask[0]);
	rt_task_resume(&mtask[1]);
	return 0;
}
Ejemplo n.º 6
0
Archivo: shm.c Proyecto: ArcEye/RTAI
int init_module (void)
{
	RTIME tick_period;
	RTIME now; 
#ifdef SHM_DEBUG
	int size = SHMSIZ ;
	unsigned long vaddr, paddr;
#endif
	shm = (int *)rtai_kmalloc(nam2num(SHMNAM), SHMSIZ);
	shm = (int *)rtai_kmalloc(nam2num(SHMNAM), SHMSIZ);
	shm = (int *)rtai_kmalloc(nam2num(SHMNAM), SHMSIZ);
	shm = (int *)rtai_kmalloc(nam2num(SHMNAM), SHMSIZ);
	if (shm == NULL)
		return -ENOMEM;
	memset(shm, 0, SHMSIZ);
#ifdef SHM_DEBUG
	/* Show physical addresses of */
	vaddr = (unsigned long)shm;
	while (size > 0)
	{
		paddr = kvirt_to_pa(vaddr);
		printk("vaddr=0x%lx paddr=0x%lx\n", vaddr, paddr); 
		vaddr += PAGE_SIZE;
		size -= PAGE_SIZE;
	}
#endif

	rt_task_init(&thread, fun, 0, STACK_SIZE, 0, 0, 0);
	tick_period = start_rt_timer(nano2count(TICK_PERIOD));
	now = rt_get_time();
	rt_task_make_periodic(&thread, now + tick_period, tick_period*PERIOD_COUNT);

	return 0;
}
Ejemplo n.º 7
0
int main(void)
{
	unsigned long hrttsk_name = nam2num("HRTTSK");
	struct sched_param mysched;

	mysched.sched_priority = sched_get_priority_max(SCHED_FIFO);
	if( sched_setscheduler( 0, SCHED_FIFO, &mysched ) == -1 ) {
		puts("ERROR IN SETTING THE SCHEDULER");
		perror("errno");
		exit(0);
 	}
 	if (!(hrttsk = rt_task_init(hrttsk_name, 1, 0, 0))) {
		printf("CANNOT INIT TESTB MASTER TASK\n");
		exit(1);
	}

	rt_set_usp_flags_mask(FORCE_SOFT);
	rt_task_suspend(hrttsk);
	printf("BACKGROUND REAL TIME TASK IS HARD .....\n");
	mlockall(MCL_CURRENT | MCL_FUTURE);

	rt_make_hard_real_time();
	while(rt_is_hard_real_time(hrttsk)) {
		rt_task_wait_period();
	}
	printf("..... BACKGROUND REAL TIME TASK IS SOFT NOW, YOU CAN KILL IT BY HAND\n");
	rt_task_delete(hrttsk);
	while(1) { sleep(3); printf("BACKGROUND PROCESS STILL RUNNING\n"); }
}
Ejemplo n.º 8
0
int main(int argc, char *argv[])
{
        RT_TASK *task;
        struct sockaddr_in addr;
	int i, srvport;

        if (!(task = rt_task_init(nam2num("TSKCOD"), 0, 0, 0))) {
                printf("CANNOT INIT TASK CODE\n");
                exit(1);
        }
        comnode = 0;
        if (argc == 2 && strstr(argv[1], "ComNode=")) {
              	inet_aton(argv[1] + 8, &addr.sin_addr);
                comnode = addr.sin_addr.s_addr;
        }
        if (!comnode) {
                inet_aton("127.0.0.1", &addr.sin_addr);
                comnode = addr.sin_addr.s_addr;
        }
        init_module();
        for (i = 0; i < NUM_TASKS; i++) {
		rt_thread_join(thread[i]);
        }
	while ((srvport = rt_request_port(comnode)) <= 0) {
		msleep(100);
	}
	RT_sem_signal(comnode, srvport, end_sem);
	rt_release_port(comnode, srvport);
	rt_task_delete(task);
	exit(0);
}
Ejemplo n.º 9
0
void *signalSan(void *arg)
{
	RT_TASK *Task_3;

	unsigned long Task_3_name = nam2num("TSK_3") + i++;
	time_t aclock;
	time_t clockNow;
	int timeEx, begin_3;
	int count = 0;
	struct tm *newtime;

	Task_3 = rt_task_init(Task_3_name, 0, 0, 0);

//	if(!(Task_3 = rt_task_init_schmod(Task_3_name,3,0,0,SCHED_FIFO,1))) {
//		printf("CANNOT INIT HANDLER TASK > Task 3 <\n");
//		exit(1);
//	}
	rt_allow_nonroot_hrt();

        rt_make_hard_real_time();

	rt_task_make_periodic(Task_3, rt_get_time(), sampling * 30);
	rt_change_prio(Task_3, 3);

	begin_3 = begin;
	while (count < 20) {
		rt_sem_wait(rMutex);
		time(&aclock); // Pega tempo em segundos.
		newtime = localtime(&aclock);


		printf(" Signal 3 =======> %s", asctime(newtime));

		sleep(1);

		time(&aclock); // Pega tempo em segundos.
		newtime = localtime(&aclock);

		printf(" Signal 3 after Sleep =======> %s", asctime(newtime));


		timeEx = 3600 * newtime->tm_hour + 60 * newtime->tm_min + newtime->tm_sec;
		if( (timeEx - begin_3) > 15 )
			printf(" Time Failure of the Signal 3\n");
		else printf(" Time Correct of the Signal 3\n");
		begin_3 = timeEx + (15 - (timeEx-begin)%15);

		rt_sem_signal(rMutex);

		rt_task_wait_period();
		count++;
	}

	rt_make_soft_real_time();
	rt_task_delete(Task_3);

	return 0;


}
Ejemplo n.º 10
0
int init_module(void)
{
    RTIME tick_period;
    int err;

    printk("%s: Loading RX%d Test module...\n", test_name, rt_port);

    err = rt_spopen(rt_port, 
		    line_param[0], line_param[1], line_param[2], 
		    line_param[3], line_param[4], line_param[5]);
    if (err) return err;
	
    /* Register error handler */
    rt_spset_err_callback_fun(rt_port, error_handler);

    /* Start RX message handler */
    rt_task_init(&thread, rx_handler, 0, STACK_SIZE, 0, 0, 0);
    rt_task_resume(&thread);

    rt_set_oneshot_mode();
    if (period) {
	tick_period = start_rt_timer(nano2count(period));
	rt_task_make_periodic(&thread, rt_get_time(), tick_period);
    }
    return 0;
}
Ejemplo n.º 11
0
int main(void)
{                   
	RT_TASK *maint;
	MSG msg = { 0, 0 };

	maint = rt_task_init(nam2num("MAIN"), 99, 0, 0);
	bx = rt_tbx_init(nam2num("BX"), TBXSIZE, ORDER);
	start_rt_timer(nano2count(TIMEBASE));
	pthread_create(&pt1, NULL, Task1, NULL);
	pthread_create(&pt2, NULL, Task2, NULL);
	pthread_create(&pt3, NULL, Task3, NULL);
	pthread_create(&pt4, NULL, Task4, NULL);
	pthread_create(&pt5, NULL, Task5, NULL);
	pthread_create(&pt6, NULL, Task6, NULL);
	pthread_create(&pt7, NULL, Task7, NULL);
	printf("\ntasks started\n");
        pthread_join(pt1, NULL);
        pthread_join(pt4, NULL);
        pthread_join(pt7, NULL);
	endall = 1;
	rt_tbx_broadcast(bx, (char*)&msg, sizeof(msg));
        pthread_join(pt2, NULL);
        pthread_join(pt3, NULL);
        pthread_join(pt5, NULL);
        pthread_join(pt6, NULL);
	rt_tbx_delete(bx);
	rt_task_delete(maint);
	stop_rt_timer();
	printf("\n\nEND\n\n");
	return 0;
}
Ejemplo n.º 12
0
int init_module(void)
{
        comnode  = ddn2nl(ComNode);
        tasknode = ddn2nl(TaskNode);
	rt_task_init(&thread, start_task_code, 0, 4000, 10, 0, 0);
	rt_task_resume(&thread);
	return 0;
}
Ejemplo n.º 13
0
int init_module(void)
{
    unsigned int            local_ip;
    unsigned int            server_ip = rt_inet_aton(server_ip_s);
    struct rtnet_callback   callback  = {echo_rcv, NULL};


    if (strlen(local_ip_s) != 0)
        local_ip = rt_inet_aton(local_ip_s);
    else
        local_ip = INADDR_ANY;

    if (interval < 1) interval = 1;
    if (interval > 1000) interval = 1000;

    if (packetsize < 1) packetsize = 1;
    if (packetsize > 1400) packetsize = 1400;

    printk("***** start of rt_client ***** %s %s *****\n", __DATE__, __TIME__);
    printk("local  ip address %s=%08x\n", local_ip_s, local_ip);
    printk("server ip address %s=%08x\n", server_ip_s, server_ip);
    printk("interval = %d\n", interval);
    printk("packetsize = %d\n", packetsize);
    printk("start timer %d\n", start_timer);

    rtf_create(PRINT, 8000);

    /* create rt-socket */
    sock = socket_rt(AF_INET,SOCK_DGRAM,0);

    /* bind the rt-socket to local_addr */
    memset(&local_addr, 0, sizeof(struct sockaddr_in));
    local_addr.sin_family = AF_INET;
    local_addr.sin_port = htons(RCV_PORT);
    local_addr.sin_addr.s_addr = local_ip;
    bind_rt(sock, (struct sockaddr *)&local_addr, sizeof(struct sockaddr_in));

    /* set server-addr */
    memset(&server_addr, 0, sizeof(struct sockaddr_in));
    server_addr.sin_family = AF_INET;
    server_addr.sin_port = htons(SRV_PORT);
    server_addr.sin_addr.s_addr = server_ip;

    /* set up callback handler */
    ioctl_rt(sock, RTNET_RTIOC_CALLBACK, &callback);

    if (start_timer) {
        rt_set_oneshot_mode();
        start_rt_timer(0);
    }

    rt_task_init(&rt_task,(void *)process,0,4096,10,0,NULL);
    rt_task_make_periodic_relative_ns(&rt_task, 1000000,
                                      (RTIME)interval * 1000000);

    return 0;
}
Ejemplo n.º 14
0
int init_module(void)
{
    rt_task_init(&parent_task, parent_func, 0, STACK_SIZE, 0, 0, 0);
    rt_set_oneshot_mode();
    period = start_rt_timer((int) nano2count(TICK_PERIOD));
    rt_set_runnable_on_cpus(&parent_task, RUN_ON_CPUS);
    rt_task_resume(&parent_task);
    return 0;
}
Ejemplo n.º 15
0
int init_module(void)
{
	printk("Conditional semaphore test program.\n");
	printk("Wait for all tasks to end, then type: ./rem.\n\n");
	start_rt_timer(nano2count(TICK));
	rt_cond_init(&cond);
	rt_mutex_init(&mtx);
	rt_task_init(&task1, task_func1, 0, RT_STACK, 0, 0, 0);
	rt_task_init(&task2, task_func2, 0, RT_STACK, 1, 0, 0);
	rt_task_init(&task3, task_func3, 0, RT_STACK, 2, 0, 0);
	rt_task_init(&task4, task_func4, 0, RT_STACK, 3, 0, 0);
	rt_task_resume(&task1);
	rt_task_resume(&task2);
	rt_task_resume(&task3);
	rt_task_resume(&task4);
	printk("Do not panic, wait 2 s, till task3 times out.\n\n");
	return 0;
}
Ejemplo n.º 16
0
Archivo: mbxdel.c Proyecto: cjecho/RTAI
int init_module(void)
{
	int i;
        rt_set_oneshot_mode();
	start_rt_timer(0);
	rt_mbx_init(&mbx, 5);
	for (i = 0; i < NUM_TASKS; i++) {
		rt_task_init(&task[i], fun1, i, STACK_SIZE, 0, 0, 0);
		rt_task_resume(&task[i]);
	}
	rt_task_init(&task[NUM_TASKS], fun2, NUM_TASKS, STACK_SIZE, 1, 0, 0);
	rt_task_resume(&task[NUM_TASKS]);
	while (atomic_read(&cleanup) < (NUM_TASKS + 1)) {
		current->state = TASK_INTERRUPTIBLE;
		schedule_timeout(HZ/10);
	}
	return 0;
}
Ejemplo n.º 17
0
int init_module(void)
{
	RTIME period;
	rt_task_init(&agentask, fun, 0, STACK_SIZE, 0, 0, 0);
	rt_set_oneshot_mode();
	period = start_rt_timer((int) nano2count(TICK_PERIOD));
	rt_task_make_periodic(&agentask, rt_get_time() + period, period);
	return 0;
}
Ejemplo n.º 18
0
int init_module(void)
{
	tasknode = ddn2nl(TaskNode);
	rt_mbx_init(&mbx, 1);
	rt_register(nam2num("HDLMBX"), &mbx, IS_MBX, 0);
	rt_task_init(&sup_task, sup_fun, 0, 2000, 1, 0, 0);
	rt_task_resume(&sup_task);
	rt_request_timer(timer_tick, imuldiv(PERIOD, FREQ_8254, 1000000000), 0);
	return 0;
}
Ejemplo n.º 19
0
static int
__latency_init(void)
{

	/* XXX check option ranges here */

	/* register a proc entry */
#ifdef CONFIG_PROC_FS
	create_proc_read_entry("rtai/latency_calibrate", /* name             */
	                       0,			 /* default mode     */
	                       NULL, 			 /* parent dir       */
			       proc_read, 		 /* function         */
			       NULL			 /* client data      */
	);
#endif

	rtf_create(DEBUG_FIFO, 16000);	/* create a fifo length: 16000 bytes */
	rt_linux_use_fpu(use_fpu);	/* declare if we use the FPU         */

	rt_task_init(			/* create our measuring task         */
			    &thread,	/* poiter to our RT_TASK             */
			    fun,	/* implementation of the task        */
			    0,		/* we could transfer data -> task    */
			    3000,	/* stack size                        */
			    0,		/* priority                          */
			    use_fpu,	/* do we use the FPU?                */
			    0		/* signal? XXX                       */
	);

	rt_set_runnable_on_cpus(	/* select on which CPUs the task is  */
		&thread,		/* allowed to run                    */
		RUN_ON_CPUS
	);

	/* Test if we have to start the timer                                */
	if (start_timer || (start_timer = !rt_is_hard_timer_running())) {
		if (timer_mode) {
			rt_set_periodic_mode();
		} else {
			rt_set_oneshot_mode();
		}
		rt_assign_irq_to_cpu(TIMER_8254_IRQ, TIMER_TO_CPU);
		period_counts = start_rt_timer(nano2count(period));
	} else {
		period_counts = nano2count(period);
	}

	loops = (1000000000*avrgtime)/period;

	/* Calculate the start time for the task. */
	/* We set this to "now plus 10 periods"   */
	expected = rt_get_time() + 10 * period_counts;
	rt_task_make_periodic(&thread, expected, period_counts);
	return 0;
}
Ejemplo n.º 20
0
int main(void)
{
	int i, indx[NTASKS];       
	unsigned long mytask_name = nam2num("MASTER");

	signal(SIGINT, endme);

 	if (!(mytask = rt_task_init(mytask_name, 1, 0, 0))) {
		printf("CANNOT INIT TASK %lu\n", mytask_name);
		exit(1);
	}
	printf("MASTER INIT: name = %lu, address = %p.\n", mytask_name, mytask);

	sem = rt_sem_init(10000, 0); 
	rt_set_oneshot_mode();
//	rt_set_periodic_mode();
	start_rt_timer(0);

	for (i = 0; i < ntasks; i++) {
		indx[i] = i;
		if (!(task[i] = rt_thread_create(thread_fun, &indx[i], 10000))) {
			printf("ERROR IN CREATING THREAD %d\n", indx[i]);
			exit(1);
 		}       
 	}       

	for (i = 0; i < ntasks; i++) {
		while (!rt_get_adr(taskname(i))) {
			rt_sleep(nano2count(20000000));
		}
	}

	for (i = 0; i < ntasks; i++) {
		rt_send(rt_get_adr(taskname(i)), (unsigned long)sem);
	}

	for (i = 0; i < ntasks; i++) {
		rt_sem_wait(sem);
	}

	for (i = 0; i < ntasks; i++) {
		while (rt_get_adr(taskname(i))) {
			rt_sleep(nano2count(20000000));
		}
	}

	for (i = 0; i < ntasks; i++) {
		rt_thread_join(task[i]);
	}
	rt_sem_delete(sem);
	stop_rt_timer();
	rt_task_delete(mytask);
	printf("MASTER %lu %p ENDS\n", mytask_name, mytask);
	return 0;
}
Ejemplo n.º 21
0
void *ThreadImplLxrt35::runThread(void *arg)
{
  ThreadImplLxrt35 *self = static_cast<ThreadImplLxrt35*>(arg);

  if (self->m_rt_start_sync == NULL)
  {
    // Technically, this can never happen because this condition is
    // already checked in the Start() function. But who knows!
    PRINTF("ERROR: NULL thread start barrier!\n");
  }
  else
  {
    self->m_rt_task = rt_task_init(getpid() + pthread_self_rt(), abs(self->m_priority),
                                   DEFAULT_STACK_SIZE, 0);
    if (self->m_rt_task == NULL)
    {
      PRINTF("ERROR: Cannot initialize LXRT task %lu!\n", self->m_thread_id);
      PRINTF("       Probably another thread with the same name already exists.\n");

      // Let the thread, which started us, continue!
      pthread_barrier_wait_rt(self->m_rt_start_sync);
    }
    else
    {
      if (self->m_priority < 0)
      {
        rt_make_hard_real_time();
        if (!rt_is_hard_real_time(rt_buddy()))
        {
          PRINTF("ERROR: Setting thread %lu to hard real-time failed!\n", self->m_thread_id);
        }
        else
        {
          // Everything worked as expected, so no message here.
        }
      }
      else
      {
        // This is a soft realtime thread, so nothing additional has
        // to be done here.
      }

      pthread_barrier_wait_rt(self->m_rt_start_sync);

      self->m_thread->runThread();

      // Remark: It does not hurt to call this in a soft realtime
      // thread, so just skip the hard realtime test.
      rt_make_soft_real_time();
    }
  }

  return NULL;
}
Ejemplo n.º 22
0
int main(void)
{
	int pid;
	char ch;
	char k = 'k';
	RT_TASK *mytask;
	MBX *Keyboard;

	menu();
	pid = fork();
	if (!pid) {
		execl("./screen", "./screen", NULL);
	}
	sleep(1);

 	if (!(mytask = rt_task_init(nam2num("KBRTSK"), 10, 0, 0))) {
		printf("CANNOT INIT KEYBOARD TASK\n");
		exit(1);
	}

 	if (!(Keyboard = rt_get_adr(nam2num("KEYBRD")))) {
		printf("CANNOT FIND KEYBOARD MAILBOX\n");
		exit(1);
	}

	if (rt_mbx_send(Keyboard, &k, 1) > 0 ) {
		fprintf(stderr, "Can't send initial command to RT-task\n");
		exit(1);
	}

	do {
		ch = get_key();
		if (ch == 'p' || ch == 'P') {
			menu();
		}
		if (ch != 'f' && rt_mbx_send_if(Keyboard, &ch, 1) > 0 ) {
			fprintf(stderr, "Can't send command to RT-task\n");
		}
	} while (ch != 'f');
	ch = 'r';
	rt_mbx_send(Keyboard, &ch, 1);
	ch = 'c';
	rt_mbx_send(Keyboard, &ch, 1);
	ch = 'f';
	rt_mbx_send(Keyboard, &ch, 1);
	rt_task_resume(rt_get_adr(nam2num("MASTER")));
	while (rt_get_adr(nam2num("MASTER"))) {
		rt_sleep(nano2count(1000000));
	}
	kill(pid, SIGINT);
	rt_task_delete(mytask);
	stop_rt_timer();
	exit(0);
}
Ejemplo n.º 23
0
int init_module(void)
{
	rt_task_init(&thread, fun, 0, 3000, 0, 0, 0);
	rt_set_oneshot_mode();
	period = start_rt_timer(nano2count(PERIOD));
	expected = rt_get_time() + 10*period;
	rt_task_make_periodic(&thread, expected, period);
//	rt_printk("\n\n*** 'LATENCY_8254 IN USE %d", LATENCY_8254);
	printk("\n*** Wait %d seconds for it ... ***\n\n", (int)(((long long)SKIP*(long long)PERIOD)/1000000000));
	return 0;
}
Ejemplo n.º 24
0
int main(void)
{
	RT_TASK *sending_task ;
	SEM *shmsem, *agentsem;
	int i, *shm, shm_size, count;
	unsigned long chksum;

	struct sched_param mysched;

	mysched.sched_priority = 99;

	if( sched_setscheduler( 0, SCHED_FIFO, &mysched ) == -1 ) {
	puts(" ERROR IN SETTING THE SCHEDULER UP");
	perror( "errno" );
	exit( 0 );
 	}       

	mlockall(MCL_CURRENT | MCL_FUTURE);

	sending_task = rt_task_init(nam2num("STSK"), 0, 0, 0);
	shmsem   = rt_get_adr(nam2num("SHSM"));
	agentsem = rt_get_adr(nam2num("AGSM"));
	shm = rtai_malloc(nam2num("MEM"), 1);
	shm_size = shm[0];
	count = COUNT;
	while(count--) {
		printf("SENDING TASK WAIT ON SHMSEM\n");
		rt_sem_wait(shmsem);
		printf("SENDING TASK SIGNALLED ON SHMSEM\n");
			if (!(shm[0] = ((float)rand()/(float)RAND_MAX)*shm_size) || shm[0] > shm_size) {
				shm[0] = shm_size;
			}
			chksum = 0;
			for (i = 1; i <= shm[0]; i++) {
				shm[i] = rand();
				chksum += shm[i];
			}
			shm[shm[0] + 1] = chksum;
			printf("STSK: %d CHECKSUM = %lx\n", count, chksum);
		printf("SENDING TASK SIGNAL AGENTSEM\n");
		rt_sem_signal(agentsem);
	}
	printf("SENDING TASK LAST WAIT ON SHMSEM\n");
	rt_sem_wait(shmsem);
	printf("SENDING TASK SIGNALLED ON SHMSEM\n");
	shm[0] = 0;
	printf("SENDING TASK LAST SIGNAL TO AGENTSEM\n");
	rt_sem_signal(agentsem);
	printf("SENDING TASK DELETES ITSELF\n");
	rt_task_delete(sending_task);
	printf("END SENDING TASK\n");
	return 0;
}
Ejemplo n.º 25
0
int init_module(void)
{
	int i;

#ifdef ONE_SHOT
	rt_set_oneshot_mode();
#endif
	rt_task_init(&thread[0], driver, 0, STACK_SIZE, 0, 0, 0);
	for (i = 1; i < NTASKS; i++) {
		rt_task_init(&thread[i], fun, i, STACK_SIZE, 0, 0, 0);
	}
	tick_period = start_rt_timer(nano2count(TICK_PERIOD));
	rt_assign_irq_to_cpu(TIMER_8254_IRQ, TIMER_TO_CPU);
	for (i = 0; i < NTASKS; i++) {
		rt_task_resume(&thread[i]);
	}
	for (i = 0; i < NTASKS; i++) {
		rt_set_runnable_on_cpus(&thread[i], RUN_ON_CPUS); 
	}
	return 0;
}
Ejemplo n.º 26
0
void parent_func(int arg) 
{
    int i;

    rt_printk("Starting parent task %d\n", arg);
    for (i = 0; i < NUM_CHILDREN; i++) {
    	rt_task_init(&child_task[i], child_func, i, STACK_SIZE, PRIORITY, 0, 0);
	rt_set_task_trap_handler(&child_task[i], 14, my_trap_handler);
	rt_task_make_periodic(&child_task[i], rt_get_time() + period, period*i);
    }
    rt_task_suspend(rt_whoami());
}
Ejemplo n.º 27
0
int init_module(void)
{
	RTIME tick_period;
	rtf_create_using_bh(CMDF, 4, 0);
#ifdef ONE_SHOT
	rt_set_oneshot_mode();
#endif
	tick_period = start_rt_timer(nano2count(TICK_PERIOD));
	rt_task_init(&thread, intr_handler, 0, STACK_SIZE, 0, 0, 0);
	rt_task_make_periodic(&thread, rt_get_time() + 2*tick_period, tick_period);
	return 0;
}
Ejemplo n.º 28
0
/***
 *	rt_stack_mgr_init
 */
int rt_stack_mgr_init (struct rtnet_mgr *mgr)
{
	int ret = 0;

	if ( (ret=rt_mbx_init (&(mgr->mbx), sizeof(struct rtnet_msg))) )
		return ret;
	if ( (ret=rt_task_init(&(mgr->task), &do_stacktask, (int)mgr, 4096, RTNET_STACK_PRIORITY, 0, 0)) )
		return ret;
	if ( (ret=rt_task_resume(&(mgr->task))) )
		return ret;

	return (ret);
}
Ejemplo n.º 29
0
int init_module(void)
{
	int i;

	thread = (RT_TASK *)kmalloc(NTASKS*sizeof(RT_TASK), GFP_KERNEL);
	rt_rwl_init(&rwl);
	rt_set_oneshot_mode();
	start_rt_timer(0);
	for (i = 0; i < NTASKS; i++) {
		extcnt[i] = 999999;
		rt_task_init(&thread[i], fun, i + 1, STACK_SIZE, NTASKS - i, 0, 0);
		rt_task_resume(&thread[i]);
	}
	return 0;
}
Ejemplo n.º 30
0
Archivo: sound.c Proyecto: ArcEye/RTAI
int main(void)
{
	pthread_t thread;
	unsigned int player, cnt;
	unsigned long msg;
	RT_TASK *mytask;
	MBX *mbx;
	char data[BUFSIZE];

	signal(SIGINT, endme);
	rt_allow_nonroot_hrt();

	if ((player = open("../../../share/linux.au", O_RDONLY)) < 0) {
		printf("ERROR OPENING SOUND FILE (linux.au)\n");
		exit(1);
	}
 	if (!(mytask = rt_task_init(nam2num("SNDMAS"), 2, 0, 0))) {
		printf("CANNOT INIT MASTER TASK\n");
		exit(1);
	}
	mlockall(MCL_CURRENT | MCL_FUTURE);
	printf("\nINIT MASTER TASK %p\n\n(CTRL-C TO END EVERYTHING)\n", mytask);

	mbx = rt_typed_named_mbx_init("SNDMBX", 2000, FIFO_Q);
	rt_set_oneshot_mode();
	start_rt_timer(0);
	thread = rt_thread_create(intr_handler, NULL, 10000);
	rt_mbx_receive(mbx, &data, 1);

	while (!end) {	
		lseek(player, 0, SEEK_SET);
		while(!end && (cnt = read(player, &data, BUFSIZE)) > 0) {
			rt_mbx_send(mbx, data, cnt);
		}
	}

	rt_rpc(rt_get_adr(nam2num("SOUND")), msg, &msg); 
	while (rt_get_adr(nam2num("SOUND"))) {
		rt_sleep(nano2count(1000000));
	}
	rt_task_delete(mytask);
	rt_mbx_delete(mbx);
	stop_rt_timer();
	close(player);
	printf("\nEND MASTER TASK %p\n", mytask);
	rt_thread_join(thread);
	return 0;
}