Coder Social home page Coder Social logo

pkernel's Introduction

pkernel

A small RTOS for ARM Cortex M3/4

pkernel is a very small multitasking kernel (RTOS) for Cortex M3/M4 microcontrollers, written in C in most parts and in assembly in as less code segments as possible

Features

Some of the features of pkernel are:

  • Supports privileged and unprivileged processes.
  • Processes can exit
  • A process can create processes
  • Provide a very basic Unix-like cron capability for process time scheduling.
  • Supports services. Services are small functions pkernel calls from inside SysTick ISR in a strict periodical manner
  • Supports sleep and stop mode.
  • Supports service running mode. pkernel runs without any call to processes and in only keeps alive services in sleep mode
  • Support syscalls like: exit(), sleep(), wait(), signal(), lock(), unlock()
  • Provide a very basic memory management via malloc-free (use with care).

A small example

#include "pkernel.h"
void pr_1 (void) {
   // process 1 code
   while (1) {
      // usually inside a loop
   }
}
void pr_2 (void) {
   // process 2 code
   while (1) {
      // usually inside a loop
   }
}
int main (void) {
   // init with 320bytes kernel stack, TICK_FREQ for system frequency and MCU clock = CLOCK
   kinit ((size_t)320, CLOCK, TICK_FREQ);  
   knew (&pr_1, (size_t)320, 1, 0);    // 320 byte stack for pr_1(), set "nice" flag and not set "fit" flag
   knew (&pr_2, (size_t)320, 1, 0);    // 320 byte stack for pr_1(), set "nice" flag and not set "fit" flag
   krun ();    // start pkernel
   while (1);  // Unreachable.
}

In the above example we create 2 process functions pr_1() and pr_2(). In the main function we initialize pkernel with the desired memory size for privileged process stack (idle process for example), the desired pkernel frequency (TICK_FREQ) and the hardware CLOCK of the MCU. Next we register the two processes with 320 bytes of stack for each and run the kernel. After that point we will never return to main.

pkernel's People

Contributors

hoo2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.