[Rtai] Issue with kmalloc in rttask

Sneha Mistry sneha0930 at gmail.com
Thu Feb 5 09:03:35 CET 2009


I am using 2.6.22 kernel with patch rtai 3.6.1. Can we use
rtai_kmalloc inside RTTASK which has been created using
rt_task_init_cpuid() and made periodic using rt_task_make_periodic().
rtai_kmalloc returns proper address if called from init_module but
returns '0' when called from the RTTASK.

#define TIMERTICKS 100000

static RT_TASK TASK1;
static RTIME tick_period;
int *var;

static void test_fun(void)
{
	var = rtai_kmalloc(nam2num("101"), sizeof(int));
	printk("var : %d \n", var);

	rt_task_wait_period();
}

int init_module(void)
{
	rt_task_init_cpuid(&TASK1, test_fun, 0, 2000, 0, 1, 0, 0);

	tick_period = 5*start_rt_timer(nano2count(TIMERTICKS));

	rt_task_make_periodic(&TASK1, rt_get_time()+tick_period, tick_period);
	return 0;
}

void cleanup_module(void)
{
	stop_rt_timer();
	rt_busy_sleep(5*TIMERTICKS);
	rt_task_delete(&TASK1);
	rtai_kfree(nam2num("101"));
}


More information about the Rtai mailing list