Re: On thread scheduling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sep 14, 2007, at 18:40:00, Heikki Orsila wrote:
Consider a simple embedded system:

void interrupt_handler(void)
int main(void)

I would like to "emulate" this system with a workstation to make development faster. I would create two threads, one executing the main() function, and the other occasionally calling interrupt_handler(). Before interrupt_handler() is called, the main () thread should be stopped asynchronously.

Actually you probably just want to do this with an ordinary single- threaded program. Just do your main() thing normally and schedule a signal-based timer at program start (or whenever you actually set up your periodic interrupt source); the timer signal-handler will act as the interrupt handler. Alternatively you could have 2 threads where the *only* thing the second thread does is a timed poll() loop on an FD where it reads commands from the main thread. When the main thread wants to change the interval-between-interrupts or some other interrupt configuration it writes the info down the FD to the alternate thread which actually sets up the change. The main program then continues running and periodically receives its SIGUSR1 or whatever from the other thread and uses that as the interrupt.

Cheers,
Kyle Moffett

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux