> I found that the rtl_hard_enable_irq() has no problem.
> because if i use like bottom .. it won't crash.
> 
> It's a module counting received interrupts. When it got 4 interrupts,
> append it to linux.
> 

Are you shure that this works ??
If it does you have very tolerant hardware...
>                 case IRQ1 :
>                         int1++;
>                         if (int1>=4) {
>                                 rtl_global_pend_irq(irq);
>                                 int1=0;
>                         } else {
>                                 rtl_hard_enable_irq(irq);
>                         }

The problem you describe sounds like a hardware software 
synchronisation problem 

If you look at the code below - it will work in non-periodic mode
ok - as this simply delays but (unless they are too fast) does not
loos interrupts. In periodic mode the keyboard will have substantial
problem and be more or less unusable - but it will work if you type 
very slowly or use a smal value for period.

So I would suggest checking if your hardware is not expecting
some action on the side of the handler , the case of the reboot I only
know from level triggert DAQ cards that must actively be resetted after
each interrupt or you have a permanennt interrupt and the box will ither
lock up (as its busy all the time in the interrupt handler) or it will
reboot. 

you might want to check if your system works with threads woken from the
handler - I doubt that this is actually an rtlinux problem, and woule expect
your setup to work properly with suspend/wackup instead of make_periodic/wait

hofrat

----int_thread.c----
#include <rtl.h>
#include <pthread.h>
#include <rtl_fifo.h>
#include <rtl_time.h>
#include <rtl_sched.h>
#include <rtl_sync.h>
#include <rtl_core.h>

//#define PERIODIC 1
#define IRQ1 1  // use the keypord as interrupt source 
                // note that the keyborad will not work
                // coreclty in periodic mode .
long long int1=0;
pthread_t thread;

unsigned int int_thread_handler(unsigned int irq, struct pt_regs *regs)
{
        int1++;
#ifndef PERIODIC
        pthread_wakeup_np (thread);
#endif
        rtl_hard_enable_irq(irq);
        return 0;
}

void *pend_thread(void *t) {

#ifdef PERIODIC
        hrtime_t period;
        period=1000000000;
        pthread_make_periodic_np(pthread_self(),gethrtime(),period);
#endif

        while(1) {
#ifdef PERIODIC
                pthread_wait_np();
#else
                pthread_suspend_np(pthread_self());
#endif
                rtl_global_pend_irq(IRQ1);              
                rtl_printf("Interrupt %d count: %d\n",IRQ1,int1);
        }
}
int init_module(void)
{
        int ret;
        pthread_attr_t attr;
        struct sched_param sched_param;

        ret = rtl_request_irq(IRQ1, int_thread_handler);
        if (ret) {
                printk("failed to get irq%d: %d\n", IRQ1, ret);
        } else {printk("got irq%d\n", IRQ1); }

        pthread_attr_init(&attr);
        sched_param.sched_priority = 0;
        pthread_attr_setschedparam(&attr, &sched_param);
        pthread_create(&thread, &attr, pend_thread, NULL);

        rtl_hard_enable_irq(IRQ1);

        return 0;
}

void cleanup_module(void)
{
        rtl_free_irq(IRQ1);
        pthread_cancel(thread);
        pthread_join(thread, NULL);
}
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

Reply via email to