That's all; you can use it in your project now. See below how to do this.

Attention

If you need to change the configuration, you can't just edit tn_cfg.h and keep using pre-built library file: you need to rebuild the library after editing tn_cfg.h. Refer to the page Building TNeo for details.

Time ticks

The kernel needs to calculate timeouts. There are two schemes available: static tick and dynamic tick. For a quick guide, it's quite enough to just read about static tick, so, for the details on it, refer to the section Static tick and then return back here.

Starting the kernel

Quick guide on startup process

You allocate arrays for idle task stack and interrupt stack, there is a convenience macro TN_STACK_ARR_DEF() for that. It is good idea to consult the TN_MIN_STACK_SIZE to determine stack sizes (see example below).

You provide callback function like void init_task_create(void) { ... }, in which at least one (and typically just one) your own task should be created and activated. This task should perform application initialization and create all the rest of tasks. See details in TN_CBUserTaskCreate().

You provide idle callback function to be called periodically from idle task. It's quite fine to leave it empty.

Create all the rest of your tasks (since everything is initialized already so that they can proceed with their job);

Eventually, perform its primary job (the job for which task was created at all).

Basic example for PIC32

This example project can be found in the TNeo repository, in the examples/basic/arch/pic32 directory.

Attention

Before trying to build examples, please read Building TNeo page carefully: you need to copy configuration file in the tneo directory to build it. Each example has tn_cfg_appl.h file, and you should either create a symbolic link to this file from tneo/src/tn_cfg.h or just copy this file as tneo/src/tn_cfg.h.

Round-robin scheduling

TNKernel has the ability to make round robin scheduling for tasks with identical priority. By default, round robin scheduling is turned off for all priorities. To enable round robin scheduling for tasks on certain priority level and to set time slices for these priority, user must call the tn_sys_tslice_set() function. The time slice value is the same for all tasks with identical priority but may be different for each priority level. If the round robin scheduling is enabled, every system time tick interrupt increments the currently running task time slice counter. When the time slice interval is completed, the task is placed at the tail of the ready to run queue of its priority level (this queue contains tasks in the RUNNABLE state) and the time slice counter is cleared. Then the task may be preempted by tasks of higher or equal priority.

In most cases, there is no reason to enable round robin scheduling. For applications running multiple copies of the same code, however, (GUI windows, etc), round robin scheduling is an acceptable solution.