R8C Family General RTOS Concepts
Intertask communication involves sharing of data among tasks through sharing of memory space, transmission of data and etc. Few of mechanisms available for executing intertask communications includes:
Remote procedural calls (RPC)
A message queue is an object used for intertask communication through which task send or receive messages placed in a shared memory. Tasks and ISRs send and receive messages to the queue through services provided by the kernel. A task seeking for a message from an empty queue is blocked either for a duration or until a message is received. The sending and receiving of messages to and from the queue may follow 1) First In First Out (FIFO), 2) Last in First Out (LIFO) or 3) Priority (PRI) sequence. Usually, a message queue comprises of an associated queue control block (QCB), name, unique ID, memory buffers, queue length, maximum message length and one or more task waiting lists. A message queue with a length of 1 is commonly known as a mailbox.
A pipe is an object that provide simple communication channel used for unstructured data exchange among tasks. A pipe can be opened, closed, written to and read from. Traditionally, a pipe is a unidirectional data exchange facility. There are two descriptors respectively at each end of the pipe for reading and writing. Data is written into the pipe as an unstructured byte stream via one descriptor and read from the pipe in the FIFO order from the other. Unlike message queue, a pipe does not store multiple messages but stream of bytes. In addition, data flow from a pipe cannot be prioritized.
Remote procedure call (RPC) component permits distributed computing where task can invoke the execution of a another task on a remote computer, as if the task ran on the same computer.
An embedded RTOS usually strive to achieve small footprint by including only the functionality needed for the user’s applications. There are two types of memory management in RTOSs. They are Stack and Heap managements.
In a multi-tasking RTOS, each task needs to be allocated with an amount of memory for storing their contexts (i.e. volatile information such as registers contents, program counter, etc) for context switching. This allocation of memory is done using task-control block model (as mentioned in section 2.6.2). This set of memory is commonly known as kernel stack and the management process termed Stack Management.
Upon the completion of a program initialization, physical memory of the MCU or MPU will usually be occupied with program code, program data and system stack. The remaining physical memory is called heap. This heap memory is typically used by the kernel for dynamic memory allocation of data space for tasks. The memory is divided into fixed size memory blocks, which can be requested by tasks. When a task finishes using a memory block it must return it to the pool. This process of managing the heap memory is known as Heap management.
In embedded systems, system and user tasks are often scheduled to perform after a specified duration. To provide such scheduling, there is a need for a periodical interrupt to keep track of time delays and timeout. Most RTOSs today offer both “relative timers” that work in units of ticks, and “absolute timers” that work with calendar date and time. For each kind of timer, RTOSs provide a “task delay” service, and also a “task alert” service based on the signaling mechanism (e.g. event flags). Another timer service provided is in meeting task deadline by cooperating with task schedulers to determine whether tasks have met or missed their real-time deadlines.
Page 12 of 18