01.06.2013 Views

RTOS Program Models Used in Embedded Systems

RTOS Program Models Used in Embedded Systems

RTOS Program Models Used in Embedded Systems

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

J. Kopják et al. <strong>RTOS</strong> <strong>Program</strong> <strong>Models</strong> <strong>Used</strong> <strong>in</strong> <strong>Embedded</strong> <strong>Systems</strong><br />

output of flip-flop must be set to true; if the reset p<strong>in</strong> of set-reset flip-flop change<br />

to true, then the output of flip-flop must be set to false.<br />

The structure of event process<strong>in</strong>g loop is similar to the functions developed basis<br />

on state-mach<strong>in</strong>e model. The core of loop is an switch-case structure. The switch<br />

tag jumps to the selected function description based on <strong>in</strong>com<strong>in</strong>g event ID.<br />

Follow<strong>in</strong>g piece of C-language sample code illustrates the body of event<br />

process<strong>in</strong>g loop.<br />

while(1)<br />

{<br />

/* Gett<strong>in</strong>g event from event queue */<br />

if( xQueueReceive( xEventQueue, &xReceivedEvent, 0 )<br />

== pdPASS )<br />

{ // On successful reception:<br />

/* Jump to selected task based on message ID */<br />

switch ( xReceivedEvent.uiEventID )<br />

{<br />

case BUTTON: // The button has bean sent<br />

/* ... */ // the message<br />

break; // End of message process<strong>in</strong>g<br />

}<br />

case TIMER: // The timer has bean sent<br />

/* ... */ // the message<br />

break; // End of message process<strong>in</strong>g<br />

}<br />

else // There is no event wait<strong>in</strong>g to be processed:<br />

{<br />

Idle(); // The processor goes to power sav<strong>in</strong>g mode<br />

}<br />

The advantage of program based on traditional event-driven model is that the<br />

model <strong>in</strong>cludes the automatic control of processor power consumption. If the<br />

message comes when the event queue is empty the response time of program is<br />

the message process<strong>in</strong>g plus the answer generation time. The disadvantage is that<br />

the program can not rank events based on their importance and is not suitable to<br />

create modular program.<br />

Conclusions<br />

All programm<strong>in</strong>g models presented here have their own reason for existence. For<br />

smaller tasks may be useful to use design models presented at the beg<strong>in</strong>n<strong>in</strong>g of the<br />

article, for complex systems are better solutions described <strong>in</strong> the second half of the<br />

article. Complex models are us<strong>in</strong>g more processor for adm<strong>in</strong>istrative tasks <strong>in</strong>stead<br />

of real problem, thereby reduc<strong>in</strong>g the effectiveness of the processor. On battery<br />

powered solutions should be used solution where the models automatically<br />

manage the processors energy consumption.<br />

References<br />

[1] József Kopják – Dr. János Kovács, Event-driven control program models<br />

runn<strong>in</strong>g on embedded systems, 2011<br />

[2] Bruce Powel Douglass, Real-Time UML: develop<strong>in</strong>g efficient objects for<br />

embedded systems, 1998<br />

[3] Richard Barry, Us<strong>in</strong>g The Free<strong>RTOS</strong> Real Time Kernel, 2009<br />

– 170 –

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

Saved successfully!

Ooh no, something went wrong!