avatarJ3

Summary

The provided content introduces OSA/RTOS, a cooperative multi-tasking, priority-based Real-Time Operating System designed for Microchip PIC controllers, detailing its features, main concepts, and scheduling policies.

Abstract

The article "OSA / RTOS — Quick Intro — Part 1/3" presents an overview of the OSA/RTOS, a Real-Time Operating System tailored for Microchip PIC microcontrollers, including PIC10, PIC12, PIC16, PIC18, PIC24, dsPIC, as well as Atmel AVR 8-bit and STMicroelectronics STM8 controllers. It emphasizes OSA's cooperative multi-tasking nature, its small footprint, and its ability to manage tasks without needing a separate stack for each task. The system supports advanced features such as semaphores, events, messages, data queues, mutexes, and timers. The author shares their positive experience with OSA/RTOS, noting its superiority over traditional superloop and state machine approaches. The article also outlines the main concepts of OSA, including tasks as C-functions with infinite loops and context-switching services, and discusses two scheduling policies: FIFO and Round Robin, detailing their advantages and disadvantages. The author concludes by expressing enthusiasm for the OSA/RTOS system and promises further exploration in subsequent posts.

Opinions

  • The author has used OSA/RTOS extensively and finds it to be a significant improvement over conventional multi-tasking approaches.
  • OSA/RTOS is praised for its small footprint, allowing it to run on devices as small as a PIC12.
  • The author believes OSA/RTOS is an excellent introduction to the world of RTOS and multi-tasking, particularly for those considering more complex systems like Avix-RT, Q-Kernel, or uC/OS.
  • The article suggests that OSA/RTOS simplifies programming by handling secondary tasks, enabling developers to focus on core problem-solving.
  • The author expresses a preference for OSA/RTOS due to its free availability and the inclusion of full source code.
  • The enthusiasm for OSA/RTOS is clear, with the author looking forward to future exploration and sharing their learning journey in subsequent posts.

OSA / RTOS — Quick Intro — Part 1/3

Real-Time Operating System for Microchip PIC-controllers

I’ve just stumbled across OSA.

Real-Time Operating System (RTOS) for Microchip PIC, Atmel AVR 8-bit controllers, and for STMicroelectronics.

Has anyone out there used this?

I have been using OSA/RTOS a lot!

In this series of three posts I’ll give you a hint on how to run OSA/RTOS on a PIC18 Family using MikroC Pro For Pic from Microchip.

What is OSA?

1- OSA is a cooperative multi-tasking, non-preemptive, a priority based OS (RTOS) for Microchip PIC-controllers PIC10, PIC12, PIC16, PIC18, PIC24, dsPIC, for Atmel AVR 8-bit controllers, and for STMicroelectronics STM8;

2- It works very well and is superior to the conventional superloop and state machine approaches traditionally used in multi-tasking applications;

3- Its very small footprint (being co-operative, it does not need a separate stack for each task as would a preemptive RTOS) allows it to run comfortably in devices such as a PIC12 (or AVRTiny) but also works well with PIC18’s, PIC24’s and dsPIC33's;

4- It supports many of the features of full-blown RTOS’s such as semaphores (binary and counting), events, messages and data queues, mutexes, timers, etc;

5- It does come with full source code — in both C and ASM where applicable (for each supported development platform);

6- It is a great way to get you feet wet before looking into products such as Avix-RT, Q-Kernel, uC/OS and the like;

7- RTOS allows the programmer to focus on problem-oriented tasks (algorithmic, mathematical etc.) and not have to worry about secondary tasks. All secondary tasks are performed by OSA’s kernel;

8- Secondary tasks? — switching between parallel processes (e.g. keyboard scanning, output data to LCD, switching relays);

— checking timeouts, counting delays;

— finding the ready task with the highest priority and executing it;

— data exchange between different tasks using semaphores, messages, queues, flags, etc;

— task management;

— queue management;

— memory management;

— critical session control function;

— A resource kernel for guaranteed and enforced timing behavior;

It enforces data coherency;

— organize driver access, critical resources and the like;

— you’ll name it…I’m into OSA for short time:-b

9- and last but not least, being FREE makes an excellent introduction to the world of RTOS’s and multi-tasking.

Main concepts

Task

A task in OSA is a C-function. This function must contain an infinite loop which has inside it at least one service that switches task context. A simple task can look like this:

void SimpleTask (void)
{
 for (;;)            // Infinite loop
   {
     OS_Yield();     // Unconditional context switching
   }
}

Scheduler

Enforces scheduling processes for serve the Tasks.

Types of schedule policies: FIFO and Round Robin

FIFO

Task that is using the scheduling policy in FIFO mode will only be interrupted if a task with a higher priority is ready for execution.

/ * Free the CPU * /
// void _sched_yield (void);
/ * Application example * /
void main()
{
 task_A (uint8_t data)
 {
 
 While (1)
 {
 process();
 _sched_yield ();
 }
 }
}

Tasks of the same priority will be blocked until the running task releases the CPU.

FIFO
Advantages:
The simplest among the scheduling processes;
All processes tend to be attended to;
Low context exchange index.
 
 
Disadvantages:
Very responsive to the order of arrival;
If larger tasks arrive first, they will increase the average waiting time;
It does not guarantee a fast response time.
 

Round Robin

The Round Robin scheduler is similar to FIFO, but differs in the following aspect. Each task in the Round Robin scheduling policy has a certain run time, this time is called Time-Slice.

It’s a template:

Uint8_t _sched_set_interval
(
      _task_id task_id,    / * Task ID * /
      Uint8_t ms_interval
)                          / * Time-slice value in milliseconds * /
Uint8_t _sched_set_interval_ticks
(
     _task_id task_id,     / * Task ID * /
     TICK_STRUCT new_interval_ptr,
     TICK_STRUCT old_interval_ptr
)

The default time-slice value may be ten times the value of the Timer interrupt period.

Round Robin
Advantages:
All tasks end up having a regular chance of being run;
No task can monopolize the CPU;
Algorithm suitable for time-shared multi-tasking systems.
 
 
Disadvantages:
More constant context switching (not suitable for low power)
Runtime (in worst case) of undetermined task (because of time-slice).

Services :

Here is a General framework of the program:

But, anyway, here we go with a working program using MikroC Pro For PIC program!

I confess this is the my first adventure with operating systems, even more novelty in embedded systems and I’m loving it!

But this is subject for the next post. Bye for now!

10 Step-by-Step is coming soon:-)

J3 is signing off…for now…

See you around!

References:

PART 1PART 2 — PART 3

OSA/RTO-OFFICIAL SITE Wizard to configure OSA projects (v1.9) microgenios.com.br — Thinking about signing up for a Crash Course about OSA/RTOS, Embedded Systems Training? Check it out! — Thanks to Fernando Simplício and Gabriel Rosa for awesome Microcontroller coaching : Curso de Formação de Especialistas em Microcontroladores PIC.

Operating Systems
Mikroc Pro For Pic
Rtos
Osa Rto
Embedded Systems
Recommended from ReadMedium