INtime® 3.1 Software - tenAsys
INtime® 3.1 Software - tenAsys
INtime® 3.1 Software - tenAsys
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 2: Understanding INtime software architecture<br />
Round-robin scheduling<br />
INtime software also provides round-robin scheduling, where equal-priority threads<br />
take turns running. Each thread gets a time slice. If a thread is still running when its<br />
time slice expires, that thread moves to the end of a circular queue for that priority<br />
level where it waits until all threads ahead of it use up their time slices, as shown in<br />
the next figure. You can adjust the length of the time slice and set the priority level<br />
threshold where round-robin scheduling occurs.<br />
Figure 2-5. Round-robin scheduling<br />
Thread A<br />
Thread B<br />
Thread C<br />
<br />
Threads A, B, and C are of equal priority below the round-robin priority threshold.<br />
Thread A, the running thread, stops running when its time slice runs out. Thread A's state is saved<br />
and it moves to the end of the queue.<br />
Thread B, a ready thread, then becomes the running thread.<br />
Thread A runs again when all threads in the queue either finish running or are preempted when<br />
their time slice expires.<br />
Higher-priority threads still preempt any running thread in the round-robin queue,<br />
regardless of the amount of time left in its time slice.<br />
Note<br />
Round-robin scheduling cannot guarantee a predictable worst-case response to events because<br />
the number of threads in the queue varies.<br />
Handling interrupts<br />
System hardware invokes an interrupt handler in response to an asynchronous<br />
interrupt from an external source, based on its entry number in the IDT (Interrupt<br />
Descriptor Table). The handler takes control immediately and saves the register<br />
contents of the running thread so it can be restarted later. There are two ways you can<br />
service an interrupt:<br />
• Using a handler alone<br />
• Using a handler/thread combination<br />
25