Skip to contentSkip to conversation

weired behaviour around userspace interrupts

Xenomai-help Stephan Zimmermann 2 participants 5 messages Jan 22, 2007

lore
Share & tools
lore
#0 lore raw

Hello all,
I guess I found some weired memory bug in Xenomai's (userspace?) interrupt handling. When I run the attached testprogram (or another program using userspace interrupt's) it happens that 'cat /proc/xenomai/irq' delivers the following output:

linux1:/proc# cat xenomai/irq
IRQ         CPU0        CPU1
  7:           0           9         ?*çd
213:           9           0
216:        1949        1949         [timer]
217:           0           0
226:          28           0         [virtual]

As you can see, for IRQ 7 the output looks somehow confusing.

To run the attached program, you need a LPT loopback-device, simply connect pin's 9 and 10 of the parallel port. (This is not necessary to see the problem.)

Another thing I have seen, which may be related to this, happens after re-running the program. The whole /proc/xenomai directory is empty. Reloading the xeno modules doesn't help and a reboot is needed to get it working. I don't know how to reproduce it reliably.

That all happens on my AMD X2 as well as on two Pentium M machines.

Maybe someone can explain this.

Thanks in advance,
Stephan

The testprogram:
-----------------------------------------------------------
#include <iostream>
#include <sys/mman.h>
#include <assert.h>
#include "native/task.h"
#include "native/timer.h"
#include "native/queue.h"
#include "native/intr.h"

#include <sys/io.h>

RT_TASK maintask;
RT_TASK inttask;
RT_TASK intcreatortask;

#define LPT_BASE 0x378
#define LPT_INT 7

bool finish = false;

void int_task(void* cookie){
	int err = 0;
	int counter = 0;
	RT_INTR lptint;
	
	err = rt_intr_create(&lptint,"parp_int",7,0);
	std::cout << "interrupt create:" << err << std::endl;
	
	err = rt_intr_enable(&lptint);
	std::cout << "interrupt enable:" << err << std::endl;
	
	// switch int mode on
	outb_p(0x10, LPT_BASE + 2);
	
	// all pins = 0
	outb_p(0x00, LPT_BASE );
	
	while(!finish){
		err = rt_intr_wait(&lptint, 100);
		if(err >= 0 ){
			counter++;
			std::cout << "got " << err << " loop: " << counter << std::endl;
		}
	}
	
	err = rt_intr_disable(&lptint);
	std::cout << "interrupt disable:" << err << std::endl;
	
	err = rt_intr_delete(&lptint);
	std::cout << "interrupt delete:" << err << std::endl;

}

void int_creator_task(void* cookie){
	char ob = 0x00;
	for(int i = 0; i < 1000; i++){	
		rt_task_sleep(100);
		outb_p(ob,LPT_BASE);
		if(ob){
			ob = 0x00;
		}else{
			ob = 0xFF;
		}
	}
	finish = true;
}
int main(void){
	int err;
	
	std::cout << "xenomai interrupt test" << std::endl;
	mlockall(MCL_CURRENT | MCL_FUTURE);
	
	if (iopl(3)) {
		printf("iopl err\n");
		exit(1);
	}
	
	err = rt_task_shadow (&maintask,"maintask",10,0);
	std::cout << "task shadow:" << err << std::endl;
	
	err = rt_timer_set_mode(1000000);
	std::cout << "timer set mode:" << err << std::endl;
	
	rt_task_spawn(&inttask,"interrupt-task",1024,50,T_JOINABLE,int_task,NULL);
	
	rt_task_spawn(&intcreatortask,"interrupt-creator-task",1024,50,T_JOINABLE,int_creator_task,NULL);
	
	rt_task_join(&intcreatortask);
	rt_task_join(&inttask);
	
	std::cout << "task's finished, exiting" << std::endl;
	
	return 0;
}
#1 lore raw
Quoted 5 lines · Stephan Zimmermann

Hello all,
I guess I found some weired memory bug in Xenomai's (userspace?) interrupt handling. When I run the attached testprogram (or another program using userspace interrupt's) it happens that 'cat /proc/xenomai/irq' delivers the following output:

Which Xenomai version? We recently fixed some maybe related issues, both in trunk and the v2.3.x branch. Please give one of them a try as well.

Jan

#2 lore raw
Quoted 9 lines · Jan Kiszka
Quoted 5 lines · Stephan Zimmermann

Hello all,
I guess I found some weired memory bug in Xenomai's (userspace?) interrupt handling. When I run the attached testprogram (or another program using userspace interrupt's) it happens that 'cat /proc/xenomai/irq' delivers the following output:

Which Xenomai version? We recently fixed some maybe related issues, both in trunk and the v2.3.x branch. Please give one of them a try as well.

Sorry, forgot to tell you about the versions I use...
I am using Xenomai 2.3 (from Download area / stable, the version from December 26.). I guess I need to use svn to access newer versions? I will checkout and run some tests now and write again later.

Stepahn

Quoted 3 lines

Jan

#3 lore raw
In reply to Jan Kiszka
Quoted 9 lines · Jan Kiszka
Quoted 5 lines · Stephan Zimmermann

Hello all,
I guess I found some weired memory bug in Xenomai's (userspace?) interrupt handling. When I run the attached testprogram (or another program using userspace interrupt's) it happens that 'cat /proc/xenomai/irq' delivers the following output:

Which Xenomai version? We recently fixed some maybe related issues, both in trunk and the v2.3.x branch. Please give one of them a try as well.

I just checked out braches/v2.3.x rev 2077, patched a fresh 2.6.17.14 Kernel an rebuilded everything (was a kernel rebuild necessary?).

Seems to work for now. Thanks for your Hint.

Stephan

P.S. I think it would be great if you could announce maintenance releases for stable (and how to get them) on the xenomai website, making post's like mine disappear from the list ;)

#4 lore raw
Quoted 8 lines · Stephan Zimmermann
Quoted 7 lines · Jan Kiszka
Quoted 5 lines · Stephan Zimmermann

Hello all,
I guess I found some weired memory bug in Xenomai's (userspace?) interrupt handling. When I run the attached testprogram (or another program using userspace interrupt's) it happens that 'cat /proc/xenomai/irq' delivers the following output:

Quoted 5 lines
Quoted 2 lines

Which Xenomai version? We recently fixed some maybe related issues, both in trunk and the v2.3.x branch. Please give one of them a try as well.

I just checked out braches/v2.3.x rev 2077, patched a fresh 2.6.17.14 Kernel an rebuilded everything (was a kernel rebuild necessary?).

Simply calling "make" on the tree catches all dependencies on 2.6. If you repatched the kernel, then you may see a full rebuild then. Normally, a prepare-kernel is safe enough to catch potentially added new Xenomai files.

Quoted 9 lines

Seems to work for now. Thanks for your Hint.

Stephan

P.S. I think it would be great if you could announce maintenance releases for stable (and how to get them) on the xenomai website, making post's like mine disappear from the list ;)

Philippe does so regularly, and if you look back in Xenomai's history, you will find *a lot* of maintenance releases for previous series. The 2.3 is fairly new, and so far the critical mass for a patch release was not reached (no mission-critical bugs - though I see your issues can be quite annoying).

Jan