It's... alive!

Discussions and support about ChibiOS/NIL, the almost nil RTOS.
User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

It's... alive!

Postby Giovanni » Wed Sep 04, 2013 1:32 pm

Hi,

A small update, the convergence process between Nil (now ChibiOS/RT) and ChibiOS/RT is almost complete. Nil gained events and the API now is almost equal to the ChibiOS/RT API.

Now Nil has been integrated in the ChibiOS 3.0 development branch and is able to use the full HAL, the very same HAL used by ChibiOS/RT.

An example:

Code: Select all

/*
    Nil RTOS - Copyright (C) 2012 Giovanni Di Sirio.

    This file is part of Nil RTOS.

    Nil RTOS is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    Nil RTOS is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "hal.h"
#include "nil.h"

/*
 * Thread 1.
 */
THD_WORKING_AREA(waThread1, 128);
THD_FUNCTION(Thread1, arg) {

  (void)arg;

  while (true) {
    palSetPad(GPIOC, GPIOC_LED4);
    chThdSleepMilliseconds(500);
    palClearPad(GPIOC, GPIOC_LED4);
    chThdSleepMilliseconds(500);
  }
}

/*
 * Thread 2.
 */
THD_WORKING_AREA(waThread2, 128);
THD_FUNCTION(Thread2, arg) {

  (void)arg;

  while (true) {
    palSetPad(GPIOC, GPIOC_LED3);
    chThdSleepMilliseconds(250);
    palClearPad(GPIOC, GPIOC_LED3);
    chThdSleepMilliseconds(250);
  }
}

/*
 * Thread 3.
 */
THD_WORKING_AREA(waThread3, 128);
THD_FUNCTION(Thread3, arg) {

  (void)arg;

  /*
   * Activates the serial driver 1 using the driver default configuration.
   * PA9 and PA10 are routed to USART1.
   */
  sdStart(&SD1, NULL);
  palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(1));       /* USART1 TX.       */
  palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(1));      /* USART1 RX.       */

  while (true) {
    chnWrite(&SD1, (const uint8_t *)"Hello World!\r\n", 14);
    chThdSleepMilliseconds(2000);
  }
}

/*
 * Threads static table, one entry per thread. The number of entries must
 * match NIL_CFG_NUM_THREADS.
 */
THD_TABLE_BEGIN
  THD_TABLE_ENTRY("blinker1", Thread1, NULL, waThread1, sizeof(waThread1))
  THD_TABLE_ENTRY("blinker2", Thread2, NULL, waThread2, sizeof(waThread2))
  THD_TABLE_ENTRY("hello", Thread3, NULL, waThread3, sizeof(waThread3))
THD_TABLE_END

/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /* This is now the idle thread loop, you may perform here a low priority
     task but you must never try to sleep or wait in this loop. Note that
     this tasks runs at the lowest priority level so any instruction added
     here will be executed after all other tasks have been started.*/
  while (true) {
  }
}


Starting from ChibiOS 3.0 Nil will be included in the same releases of the other products:
1) ChibiOS/RT
2) ChibiOS/NIL
3) ChibiOS/HAL

I love that family feeling :)

The curious among you can checkout this location: http://svn.code.sf.net/p/chibios/svn/br ... nel_3_dev/
The old Nil repository is frozen now.

Giovanni

mobyfab
Posts: 483
Joined: Sat Nov 19, 2011 6:47 pm
Location: Le Mans, France
Has thanked: 21 times
Been thanked: 30 times

Re: It's... alive!

Postby mobyfab » Thu Sep 05, 2013 12:01 pm

Nice job!

I will update my project with the new version :D

Are messages/mailboxes planned at some point ?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: It's... alive!

Postby Giovanni » Thu Sep 05, 2013 12:52 pm

Messages should be easy to do because the base mechanisms are already there. I don't want it to grow above 1KB but messages are next in queue if there is enough space.

You can take the RT mailboxes and compile them under NIL almost unmodified :)

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: It's... alive!

Postby Giovanni » Thu Sep 05, 2013 3:58 pm

Added to Nil:
1) Support for stack checking.
2) Events.
3) Port to M3/M4.
4) Simplified task declaration macros.
5) Demos for F0/F3 Discovery boards.
6) Strong commonality with ChibiOS/RT API and ports (very few differences in port files).

Giovanni

jcbarlow
Posts: 21
Joined: Sun Jul 03, 2011 6:48 am
Location: Bend, Oregon, USA

Re: It's... alive!

Postby jcbarlow » Thu Sep 05, 2013 5:55 pm

Giovanni,

In your abundant spare time :lol: could you please write up a little "executive summary" of the differences between RT and NIL in their current form (3.0).

Thanks,
Jeff

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: It's... alive!

Postby Giovanni » Thu Sep 05, 2013 8:01 pm

Hi,

Basically ChibiOS/RT is meant to be an as efficient as a fully featured RTOS can be. Nil is meant to be just as small as a viable RTOS can be. I think that Nil is more than simply viable now, I started it in order to test some concepts and I liked the result. I didn't work much on Nil because I realized immediately that without an HAL it didn't have a place so I froze the project until the new HAL was usable.

Nil and RT are very different internally even if they expose a compatible API. RT is designed to be efficient, scalable and feature-complete, Nil is meant to be small and memory-efficient.

Main differences:
1) In Nil threads cannot be created and cannot terminate, totally static. RT can start-terminate threads.
2) In Nil priorities are fixed, threads cannot change priority, this makes it impossible to implement proper mutexes with priority inheritance support.
3) Internal algorithms are less computationally efficient, Nil is basically even faster than RT (something I didn't expected to see being RT already about the fastest thing on earth right there with Road Runner) but RT scales better, so Nil is only faster when few threads are involved.

Where Nil wins hands down is memory usage, both RAM and Flash. In future RT will be aimed at "normal" 32bits devices, Nil at 8/16bits devices and lesser 32bits one (there are now very small devices from ST, NXP etc that could use a memory-efficient RTOS). This is fun considering that RT is just 6KB in its largest configuration but Nil is well below 1KB.

Giovanni

andyturk
Posts: 23
Joined: Tue May 01, 2012 7:22 pm

Re: It's... alive!

Postby andyturk » Fri Sep 06, 2013 12:16 am

Giovanni wrote:Main differences:
1) In Nil threads cannot be created and cannot terminate, totally static. RT can start-terminate threads.
2) In Nil priorities are fixed, threads cannot change priority, this makes it impossible to implement proper mutexes with priority inheritance support.
3) Internal algorithms are less computationally efficient, Nil is basically even faster than RT (something I didn't expected to see being RT already about the fastest thing on earth right there with Road Runner) but RT scales better, so Nil is only faster when few threads are involved.


I thought one of the differences was that Nil can run "tickless" while RT requires systick interrupts. Is that still a difference between them, or are both kernels capable of tickless operation now?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: It's... alive!

Postby Giovanni » Fri Sep 06, 2013 7:23 am

Hi,

RT 3.0 is able to run tickless as well.

Both are in the same repository linked in the first post.

Giovanni

jcbarlow
Posts: 21
Joined: Sun Jul 03, 2011 6:48 am
Location: Bend, Oregon, USA

Re: It's... alive!

Postby jcbarlow » Fri Sep 06, 2013 8:51 pm

Giovanni wrote:Where Nil wins hands down is memory usage, both RAM and Flash. In future RT will be aimed at "normal" 32bits devices, Nil at 8/16bits devices and lesser 32bits one (there are now very small devices from ST, NXP etc that could use a memory-efficient RTOS). This is fun considering that RT is just 6KB in its largest configuration but Nil is well below 1KB.

So... that 6KB vs 1KB is only the kernel, right? The various HAL driver modules add on from there, yes?

To me NIL sounds somewhat like Larry Barello's AVRx (which I've used before) except NIL is portable.

I'm working on a design for a distributed home automation control system. The leaf nodes will use STM32F051s and the routers will be STM32F303s I think. They'll interconnect using a token passing RS-485 network. It looks like I can hang 3 RS-485 buses off each 303. RT seems to fit the 303s well but the 051s could go either way. I'll have to study the code. (of course)

mobyfab
Posts: 483
Joined: Sat Nov 19, 2011 6:47 pm
Location: Le Mans, France
Has thanked: 21 times
Been thanked: 30 times

Re: It's... alive!

Postby mobyfab » Tue Sep 17, 2013 6:56 pm

Updated to latest SVN version, I went from 12K of code to 8.5K using LTO :D (whole project)


Return to “ChibiOS/NIL”

Who is online

Users browsing this forum: No registered users and 11 guests