[Rtai] Context switch handler not catching signals
Pawel Talaszewski
p.talaszewski at gmail.com
Fri Mar 30 15:11:25 CEST 2012
Good day,
I am experiencing difficulty with successfully invoking the context switch
handler. Please refer to the info and code below.
The latest patch hal-linux-2.6.34-x86-2.6-04.patch has been applied to the
kernel.
Magma branch used with latest change 2011-05-09 as per Changelog.
[root at netboot root]# uname -srvmpio
Linux 2.6.34-adeos #19 Mon Jul 18 08:00:02 SAST 2011 i586 i586 i386
GNU/Linux
The following modules are loaded:
[root at netboot root]# lsmod
Module Size Used by
kgeneric 2776 0
rtai_fifos 23051 0
rtai_shm 6305 0
rtai_sched 70303 2 rtai_fifos,rtai_shm
rtai_hal 16788 3 rtai_fifos,rtai_shm,rtai_sched
Simple test program listing follows:
/*****************************************************************************/
// test.c
#include <linux/kernel.h>
#include <linux/module.h>
#include <rtai.h>
#include <rtai_sched.h>
MODULE_LICENSE("GPL");
#define TICK_PERIOD 100000
#define STACK_SIZE 1024
static RT_TASK thread;
int thread_cnt = 0;
int signal_cnt = 0;
static void thread_func(long t)
{
while(1) {
thread_cnt++;
rt_task_wait_period();
}
}
static void signal(void)
{
signal_cnt++;
}
int init_module (void)
{
RTIME tick_period;
RTIME now;
int retval = 0;
rt_set_oneshot_mode();
retval = rt_task_init(&thread, thread_func, 0, STACK_SIZE, 0, 0,
signal);
if (retval != 0) {
rt_printk("ERROR! rt_task_init\n");
return 0;
}
tick_period = start_rt_timer(nano2count(TICK_PERIOD));
now = rt_get_time();
retval = rt_task_make_periodic(&thread, now + tick_period,
tick_period);
if (retval != 0) {
rt_printk("ERROR! rt_task_make_periodic\n");
return 0;
}
return 0;
}
void cleanup_module (void)
{
rt_printk("Entered thread function %d times...\n", thread_cnt);
rt_printk("Caught signal %d times...\n", signal_cnt);
stop_rt_timer();
rt_busy_sleep(10000000);
rt_task_delete(&thread);
}
/*****************************************************************************/
Output of relevant dmesg messages:
I-pipe: Domain RTAI registered.
RTAI[hal]: <magma> mounted over IPIPE-NOTHREADS 2.7-04.
RTAI[hal]: compiled with gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC)
.
RTAI[hal]: mounted (IPIPE-NOTHREADS, IMMEDIATE (INTERNAL IRQs VECTORED),
ISOL_CPUS_MASK: 0).
PIPELINE layers:
d082dfc0 9ac15d93 RTAI 200
c1433040 0 Linux 100
RTAI[malloc]: global heap size = 2097152 bytes, <BSD>.
RTAI[sched]: loaded (IMMEDIATE, UP, USER/KERNEL SPACE: <with RTAI OWN
KTASKs>, <uses LINUX SYSCALLs>, kstacks pool size = 524288 bytes.
RTAI[sched]: hard timer type/freq = 8254-PIT/1193180(Hz); default timing:
periodic; linear timed lists.
RTAI[sched]: Linux timer freq = 250 (Hz), TimeBase freq = 1193180 hz.
RTAI[sched]: timer setup = 1676 ns, resched latency = 2514 ns.
Entered thread function 72897 times...
Caught signal 0 times...
The dmesg output after kgeneric.ko is unloaded confirms that while the
thread_func is invoked numerous times, none of the context switch signals
are caught. I wish to determine if my current RTAI installation is in some
way faulty. The above code seems to be correct. If anyone can confirm the
correct execution of the above code, please provide Linux kernel, RTAI and
patch set versions used.
Any help would be greatly appreciated.
Regards,
Pawel Talaszewski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.rtai.org/pipermail/rtai/attachments/20120330/28bb1397/attachment.html>
More information about the Rtai
mailing list