Keil Logo


Information in this article applies to:

  • RTX51 Tiny Version 2
  • C51 Version 7


I have some problems understanding how to structure time sharing in a RTX51 Tiny application.

For example, in a system with 5 tasks, one of those tasks will take 10ms execution time and the remaining tasks will take 5ms each for execution. So the complete execution time is 30ms. When the default RTX Timer Tick of 10ms is used, time is equally shared among these 5 tasks when using round robin timeout. However, it seems that there is not much of a difference for a single task program (without using RTX tiny); each task would be invoked by a loop and has to wait about 30ms for next execution.

How should I structure a RTX Tiny application?

On what basis should I set the RTX Timer Tick value?


A real-time operation system like RTX Tiny helps you avoid long time delays in your application when reacting on external events, since the processing time can be split between tasks. The best way to get started with RTX51 Tiny is to work the program examples that are in the folder C51\RtxTiny2\Examples. Each program can be executed in the µVision Debugger/Simulator without real hardware:

  • Ex1: demonstrates round-robin multitasking. This is the method that you are currently using, but it is not much better than systems without an RTX Tiny real-time operating system.
  • Ex2: shows how to use time delays and signals with the os_wait function. The challenge in real-world applications is that you need to react on external events (for example a switch that is pressed). With RTX-Tiny, you can easily write tasks that perform actions on such events. It contains a powerful time management tool that allows you to delay tasks for a specific time (without blocking the processor for other tasks).
  • Traffic: is a real-world example of a time-controlled Traffic Light Controller. It shows you how to process external events and handle slow output channels like a serial interface.
  • Banking: uses code banking and shows several new features of RTX Tiny Version 2.

When you work with these examples, you will see that your existing code needs a few small modifications for RTX Tiny to get the benefits of the real-time operation system. In general, each task should use the os_wait function, which frees the CPU execution for other tasks. When you have tasks that need a lot of CPU computing time, you should periodically call the RTX Tiny function os_switch_task. This function checks if other tasks need the CPU and will execute them.

The execution of each task should be based on events which may be either a timed or a signal event in RTX Tiny. For very fast events, you may use standard interrupt functions to preprocess the data and send a signal event to a task that does the final data processing.

The best value for the RTX Timer Tick depends on the delays that you need in your system. For getting started, you should keep the default 10ms (on classic 8051 12-cycle CPU). When you have very short time delays, you may reduce this value. But keep in mind, by reducing the RTX Timer Tick value, the time consumed in the real-time kernel management is increased.



Last Reviewed: Friday, February 23, 2007

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.