21.01.2015 Views

INtime® 3.1 Software - tenAsys

INtime® 3.1 Software - tenAsys

INtime® 3.1 Software - tenAsys

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 4: About RT programming<br />

Preemptive, priority-based scheduling<br />

In a preemptive, priority-based system, some threads are more critical than others.<br />

Critical threads run first and can preempt less critical threads, as shown in this figure:<br />

Figure 4-2. Multithreading and preemptive, priority-based scheduling<br />

Event<br />

Thread A<br />

Thread B<br />

<br />

Thread A, a low-priority thread, prints data accumulated from the robotic arm in report form.<br />

Thread B, a high-priority thread, controls the robotic arm. If the arm needs to move while thread A<br />

runs, thread B preempts the print thread, then starts and moves the arm.<br />

After thread B repositions the arm, thread A finishes printing.<br />

Multithreading allows an application to respond to internal events and external<br />

interrupts, such as clock ticks from the system clock or receiver ready from a serial<br />

device, based on how critical they are. You determine the priority of threads in your<br />

application; INtime software provides the thread scheduling algorithms.<br />

When you add interrupt processing to multithreading and preemptive, priority-based<br />

scheduling, your application can respond to interrupts as they occur. Your application<br />

becomes event-driven.<br />

41

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

Saved successfully!

Ooh no, something went wrong!