What is Real time operating system's role, function in an embedded system? Describe various uCOS-II c-functions which are used to implement RTOS functions/solved?

Mumbai University > Electronics Engineering > Sem 6 > Embedded System and RTOS

mumbai university esr • 1.3k  views


The RTOS is an operating system, it is a brain of the real-time system and its response to inputs immediately. In the RTOS, the task will be completed by the specified time and its responses in a predictable way to unpredictable events.

There are different types of basic functionalities of an RTOS are following:

a. Priority based scheduler

b. System clock interrupt routine

c. Deterministic behavior

d. Synchronization and Messaging

e. RTOS service

Priority Based Scheduler

In the priority-based scheduler, most of the RTOS is between 32 and 256 possible priorities for the individual tasks or processes. This scheduler will run the process with the highest priority. If the task is running on the CPU, then the next highest priority task runs and continuous the processes.

System Clock Interrupt Routine

To perform the time sensitive operation the RTOS will provide some sort of system clocks. If there is a 1ms system clock, then you have to complete the task in 50ms. Usually, there is an API that follows you to say “In 50ms wake me up”. Hence the task would be in sleeping position until the RTOS will wake up. We have two notices that the woken up will not ensure to run exactly at that time, it depends on the priority and if the higher priority is running currently it would be delayed.

Deterministic Behavior

The RTOS moves to great length to protect that whether you have taken 100 tasks or 10 tasks, it does not make any difference in the distance to switch context and it determines the next highest priority task. In the prime area deterministic the RTOS is the interrupt handling, when the interrupt line is signaled them the RTOS immediately takes the action of the correct interrupt service routine and interrupt is handled without any delay.

Synchronization and Messaging

The synchronization and messaging provides the communication between the task of one system to another system and the messaging services are following. To synchronize the internal activities the event flag is used and to send the text messages we can use in the mailbox, pipes and message queues. In the common data areas, the semaphores are used.

(I) Semaphores (II) Event flags (III) Mailboxes (IV) Pipes (V) Message queues

RTOS Service

The most important part of the operating system is the Kernel. To monitor the hardware the task should be relieved and the responsibilities kernel manages & allocate the resources. If the task can’t obtain the CPU attention for every time, then there are some other services provide by the kernel. They are as follows:

  • Time services
  • Interrupt handling services
  • Device management services
  • Memory management services
  • Input-output services

uCOS-II functions:

i) OSInit();

It initializes uCOS – II. It does not require any arguments. It does not return any value.

ii) OSSemPend();

This function is used when a task wants an exclusive access to a resource, synchronize the activities with ISR/ task or waits for an event to occur.


prevent (a pointer to semaphore),

timeout (for a task to resume execution)

err (different types of errors)

iii) OSSemPost();

This function is used to signal a semaphore. If semaphore value is ‘0’ or more, its value is increased. If a task is waiting for semaphore, highest priority task gets semaphore.

iv) OSTaskCreate();

It is used to create task.

Function prototype-

INT8U OSTaskCreate (void(task)(void(pdata)));


task - pointer to task’s code that must be declared as void task (void*) pdata - pointer to data that is passed to task when it is created.

v) OSMBoxPost();

This function is used to send a message to task through a mailbox.

vi) OSMBoxPend();

It is used when a task requires a message to be received. This function does not return anything.

Please log in to add an answer.

Continue reading

Find answer to specific questions by searching them here. It's the best way to discover useful content.

Find more