OS48

A preemptive multitasking kernel


Navigation


Summary

OS48 is a tiny kernel OS for your Arduino sketches. It can help you to improve your productivity to develop multitasking programs on your microcontroller. The library has been written in C++ .

It works only with Arduino UNO and MEGA boards but can be adapted to others devices.

Features

  • Many preemtives scheduling algorithms including a cooperative one
  • Low power consumption if there is no activity
  • Intelligent stack overflow detection
  • Tasks management (suspend/resume/sleep a task)
  • Messaging system between tasks (send/get/wait)
  • Concurrency functions: semaphores, barriers, mutexes
  • Task statistics of CPU / memory usage
  • Software timers
  • ...

Website

I've written a tutorial on http://www.rtos48.com/. This website contains also the ZIP library to include in your sketch and the documentation of C++ classes.

Download

You can click directly here to download the lib.

Examples

Here an example to blink a LED and to send messages through the serial interface at the same time:

#include <os48.h>

using namespace os48;

Scheduler* scheduler = Scheduler::get();
Task* task1 = NULL;
Task* task2 = NULL;

void setup() {
  Serial.begin(9600);

  task1 = scheduler->createTaskTimer(&func1, 60, 200, PrHigh);
  task2 = scheduler->createTask(&func2, 60);

  pinMode(13, OUTPUT);

  scheduler->start();
}

bool func1()
{
  digitalWrite(13, HIGH);
  task()->sleep(100);
  digitalWrite(13, LOW);

  return true;
}

void func2()
{
  for (;;)
  {
    OS48_ATOMIC_BLOCK
    {
      Serial.println("HP");
    }

    task()->sleep(200);
  }
}

void loop() {}

Support

For any suggestions, bugs or questions, you can contact me at mailto:rtos47.contact@gmail.com

Share