21.01.2015 Views

INtime® 3.1 Software - tenAsys

INtime® 3.1 Software - tenAsys

INtime® 3.1 Software - tenAsys

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INtime <strong>3.1</strong> <strong>Software</strong><br />

Interrupt processing<br />

Interrupts are signals from devices such as a malfunctioning robot or interactive<br />

terminal. You connect interrupt sources to the processor through the PC’s two PICs<br />

(Programmable Interrupt Controllers).<br />

With interrupt processing, your application can handle interrupts occurring at random<br />

times (asynchronously) and can handle multiple interrupts without losing track of the<br />

running thread, or those threads waiting to run. Interrupts can occur while the<br />

processor is executing either an unrelated thread or a related thread, as shown in the<br />

next figure.<br />

Figure 4-3. Interrupt handler interrupting a thread<br />

Event<br />

PIC<br />

Processor<br />

Thread A<br />

Thread B<br />

IRQ signal<br />

IRQ handler<br />

<br />

Thread B, the running thread, repositions the robotic arm.<br />

The robotic arm malfunctions and sends an interrupt signal through the PIC.<br />

As soon as it receives the signal, the microprocessor stops the running thread and starts an<br />

interrupt handler. The interrupt handler runs in the context of thread B. No new thread is loaded;<br />

thread B’s state does not need to be saved. It remains loaded in RAM until the scheduler runs it<br />

again. Thread A, the print thread, is still waiting to run.<br />

Typically, numerous sources of interrupts exist in an application. Some of them, like<br />

the malfunctioning robotic arm, are critical; some of them are not. You assign interrupt<br />

levels (which map directly to priorities) to the interrupt sources by the order in which<br />

you connect your external sources to the PIC. INtime software handles more critical<br />

interrupts first, and keeps track of which interrupts occurred, the order in which they<br />

occurred, and which ones have not been handled.<br />

Interrupt handlers can perform very limited operations, so you typically write an<br />

interrupt handler to signal an interrupt thread. The interrupt thread's priority can be<br />

automatically assigned, based on the interrupt level of the external source.<br />

Multithreading and interrupt processing simplify expanding an application. Because of<br />

the one-to-one relationship between interrupts and threads, you add a new thread<br />

42

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!