All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] weired behaviour around userspace interrupts
@ 2007-01-22 10:46 Stephan Zimmermann
  2007-01-22 11:36 ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Stephan Zimmermann @ 2007-01-22 10:46 UTC (permalink / raw)
  To: xenomai

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;
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-01-22 13:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-22 10:46 [Xenomai-help] weired behaviour around userspace interrupts Stephan Zimmermann
2007-01-22 11:36 ` Jan Kiszka
2007-01-22 12:22   ` Stephan Zimmermann
2007-01-22 13:34   ` Stephan Zimmermann
2007-01-22 13:50     ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.