
How I ended up writing new real-time kernel - qznc
http://dmitryfrank.com/articles/how_i_ended_up_writing_my_own_kernel
======
dwwoelfel
That was a great writeup, thanks. The author has a real talent for writing
engaging explanations.

I've been making my way through _The Design and Implementation of the FreeBSD
operating System_ [1], which is a bit denser and more formal. It was nice to
read about some of the same ideas in a different implementation. I'd recommend
the book to anybody who enjoyed the post.

[1] [http://www.amazon.com/Design-Implementation-FreeBSD-
Operatin...](http://www.amazon.com/Design-Implementation-FreeBSD-Operating-
Edition/dp/0321968972)

~~~
dimonomid
Thank you for such a positive feedback!

And thanks for sharing the book, I'll probably get to it. I've read a couple
of books on Linux Kernel before writing TNeo, but haven't read anything on
FreeBSD yet.

------
hga
From the overview on Bitbucket
([https://bitbucket.org/dfrank/tneokernel](https://bitbucket.org/dfrank/tneokernel)):

 _TNeo: a real-time kernel (RTOS)

TNeo is a compact and fast real-time kernel for embedded 32/16 bits
microprocessors. It performs a preemptive priority-based scheduling and a
round-robin scheduling for the tasks with identical priority.

TNeo was born as a thorough review and re-implementation of TNKernel v2.7. The
new kernel has well-formed code, inherited bugs are fixed as well as new
features being added, it is well documented and tested carefully with unit-
tests.

Currently it is available for the following architectures:

ARM Cortex-M cores: Cortex-M0/M0+/M1/M3/M4/M4F (supported toolchains: GCC,
Keil RealView, clang, IAR)

Microchip: PIC32/PIC24/dsPIC_

Like TNKernel, it has a custom but very simple FOSS license:

 _Permission to use, copy, modify, and distribute this software in source and
binary forms and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear in
supporting documentation._

Plus the usual all caps disclaimer boilerplate.

------
jdmichal
Honest question: What's the value, if any, of using intrusive linked lists in
this context? That is, I would have handled linked lists as something like:

    
    
        struct TN_ListItem {
            TN_ListItem * prev;
            TN_ListItem * next;
            void * data;
        }
    

I can immediately see that each TN_ListItem would take up an extra word of
memory in order to store the pointer to the data. Is that the main crux of the
issue, or is there something more?

~~~
AnimalMuppet
Twice the allocations? That can matter for performance reasons.

~~~
Gracana
Or even more if the item is included in multiple lists.

------
vmorgulis
About FreeRTOS:

> First, I don't like their policy: the license states that it's forbidden to
> compare FreeRTOS to any other kernel! (...)

> FreeRTOS may not be used for any competitive or comparative purpose,
> including the publication of any form of run time or compile time metric,
> without the express permission of Real Time Engineers Ltd. (this is the norm
> within the industry and is intended to ensure information accuracy)

It's quite abusive an probably not legal.

~~~
dimonomid
Agreed. I'm not a lawyer, so not sure about legality, but since this clause is
persisted for so long in their license, it seems they have no problems with
it.

------
roymurdock
Really thorough and interesting write-up. I don't have much to add, but wanted
to express my admiration for the author's grit and perseverance on seeing a
problem through to its end.

~~~
dimonomid
Thank you very much for your feedback!

------
OJFord
This is well worth a thorough read (I admit at this point I've only properly
read the intro and a couple of (the most) interesting looking sections;
skimmed the rest) - an entertaining style and very informative.

Love the perseverance that essentially took you from "this kernel has a bug
somewhere.." to "I wrote a kernel"!

~~~
dimonomid
Thanks for the feedback!

------
blt
This was a really good article. I've never used a RTOS, but I'm getting into
robotics and I'll keep TNeo in mind if I ever need one. I'm using bigger ARM
systems capable of running Linux but I'm curious about possible performance
gains from using embedded programming style on these powerful machines.

