01.06.2013 Views

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

ackground data base search in the event that the user presses the escape key.<br />

In more involved applications, there might be a complete spectrum of concurrent activity at different<br />

priorities. Just for an example, the set of tasks within a real-time application might be as follows.<br />

Listed in priority order:<br />

■ 50 Hz Data Acquisition Loop (top priority)<br />

■ 10 Hz Data Pre-processing Loop<br />

■ 1 Hz Data Processing Loop<br />

■ 0.1 Hz Kalman Filter<br />

■ Background Loop for Integrity Self-test<br />

Event Triggered Actions<br />

Sometimes an activity is required only upon an event such as some data becoming available. For<br />

these situations a task could be made to block, awaiting the event or data arrival. For example, a task<br />

could make a blocking call on a TCP/IP port with the recv() library function. The task sleeps until<br />

some data arrives at the respective socket, or until a prescribed time-out period expires.<br />

Note that polling can usually be an alternative software design approach, as opposed to applying a<br />

dedicated task to each event or data source.<br />

Reasons not to use Multitasking<br />

While multitasking can be an ideal solution for some applications, it also has its disadvantages. Some of<br />

these disadvantages are noted here. The point is that you should not complicate an application with<br />

multiple tasks unless to do so truly makes your application simpler.<br />

Resources Expended per Task<br />

Each task requires its own stack space. This stack must be made large enough to support the<br />

system's interrupt handlers, some of which operate without a switch to a system stack. A minimum<br />

stack space of 1024 bytes is recommended.<br />

Critical Sections<br />

Objects (memory or devices) shared between tasks can lead to critical sections. A critical section is a<br />

section of code in a task which is sensitive to order of execution relative to code in some other task,<br />

such that there is a possible (prior to adding the necessary protection) firing order of the two<br />

instruction streams which leads to incorrect results.<br />

When you design your application with only a single task, it is safe to say you have no critical<br />

sections. When more than one task is used, you must beware. Due to the importance of<br />

understanding and recognizing critical sections in multitasking systems, this topic is covered in more<br />

detail below on chapter Critical Sections in Programs.<br />

Page 221 / 400

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

Saved successfully!

Ooh no, something went wrong!