You are on page 1of 3

9) Explain the inter-task Communication in RTOS?

Ans:-

• We need to be able to communicate between the different tasks in an RTOS.


Communication can take form of event, a semaphore (flag),or it can be in the form of
message sent to another task.

• The most basic communication is via an event. An event is a way for a single task to
communicate with another task. An interrupt service routine (ISR) can also send one
event to more than one task.

• Semaphores usually used to protect shared resources, for example if there is more
than one task that need to read/write to same memory. This is done so that a variable
does not change through the actions of another task while it is being addressed by the
active task.

• The principle is that you need to obtain a semaphore associated with a variable
protected in this way before reading/writing to this memory. Once you have obtained the
semaphore, on one else can read/write to this memory until you release the semaphore.

• This way you can ensure that only one task at the time reads/writes to a memory
location or variable.

• Messages allow you to send data to one or more tasks. These messages can be of
almost any size and are usually implemented as a mailbox or a queue.

• A mailbox is a FIFO buffer and each item in the mailbox has a predefined fixed size.

• A queue is a FIFO buffer and each item in the queue has a dynamic size
• There are three major differences between queues and mailbox :

1. Queues accept messages of various sizes.

2. Retrieving a message from the queue does not copy the message, but returns a
pointer to the message along with its size.

3. For queues, the retrieving function has to delete every queue message after
processing it. Otherwise the message will remain on the queue.

Fig.: Intertask Communication

You might also like