TNeoKernel
v1.03
|
This page contains quick guide on system startup and important implementation details.
For the purpose of calculating timeouts, the kernel uses a time tick timer. In TNeoKernel, this time tick timer must to be a some kind of hardware timer that produces interrupt for time ticks processing. Throughout this text, this timer is referred to as system timer. The period of this timer is determined by user (typically 1 ms, but user is free to set different value). In the ISR for this timer, it is only necessary to call the tn_tick_int_processing()
function:
TN_STACK_ARR_DEF()
for that. It is good idea to consult the TN_MIN_STACK_SIZE
to determine stack sizes (see example below).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()
.main()
you should:tn_arch_int_dis()
;tn_tick_int_processing()
gets called)tn_sys_start()
providing all necessary information: pointers to stacks, their sizes and your callback functions.TN_CBUserTaskCreate()
callback, in which your initial task is created with TN_TASK_CREATE_OPT_START
option;This example project can be found in the TNeoKernel repository, in the examples/basic/arch/pic32
directory.
tn_cfg_appl.h
file, and you should either create a symbolic link to this file from tneokernel/src/tn_cfg.h
or just copy this file as tneokernel/src/tn_cfg.h
.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.