KRNL - An Arduino Kernel - Usage and Configuration and Install

Just …

  • add a new directory krnl in sketchbook/libraries (you can find the right location in Arduino file->Preferences)

  • copy krnl.h and krnl.c to this directory

You can copy the directories sketchbook/krnl examples and sketchbook/libraries/krnl which contains SNOT

You may have to restart arduino sw after copying files into this directory

Optimization

Two important things to optimize for:

  • ram usage

  • cpu usage

Different Arduinos has from 512B up to 8 kB or RAM.

KRNL use of RAM is static and is set by call to k_init

You have to give max number of tasks, semaphores and message queues as parameters to k_init

IF you try to create more tasks, semaphores or message queues than the limit you have given by k_init SNOT will NOT start when you are calling k_start !!!

Stack

There shall be space for at least a context swicth on the stack which is approx 35 B on top of your use of local variabels in functions.

KRNL call k_stak_usage can write og Serial stack status (unused stack) for your tasks. To be able to write you have to define STAK_USAGE in krnl.h

k_unused_stak returns as name indicate unused stack for a task

rest has to be corrected /JDN

maybe not all up to date

A test setup

  • 4 tasks

  • 3 semaphores

  • 2 message queues

gives (432)*15 + 2*12 + 34 = 193B plus stak for the tasks

100B for each task gives 193 + 400B = 600B of RAM usage.

happy krnl hacking