[FUN] Preliminary results

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

[FUN] Preliminary results

Postby Giovanni » Thu Jul 05, 2012 3:48 pm

Preliminary results (95% complete code, now it compiles).

Total image size: 1284 bytes

Divided as:
Appl.Main: 76 bytes
Vectors: 192 bytes
NVIC code: 156 byes <- To be removed from the code
CRT0: 188 bytes
CM0 Port: 140 bytes
Kernel: 492 bytes :-)

Talking about a real, usable, kernel with threads, semaphores, timeouts, delays, system time, without even start optimizing.

Giovanni

Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm
Location: India

Re: [FUN] Preliminary results

Postby Abhishek » Thu Jul 05, 2012 5:37 pm

A few hours ago, I was browsing through the Nil RTOS repo. Saw the 'stub' folders full of code today. Was wondering if it's complete. It's great to hear progress Sir. I'd love to see (and test) a port on Cortex-M3 and M4 family as well.

Also, I was wondering would context switch time would be almost the same (or lesser) than ChibiOS running on the same config?

Best Regards.

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

Re: [FUN] Preliminary results

Postby Giovanni » Thu Jul 05, 2012 6:00 pm

It is too early to say considering it is not ready to run yet. My guess is that it will be as fast as ChibiOS for very few threads and will get slower much faster than ChibiOS when the number of threads increases because it is not designed for scalability, it is meant to be small and simple.

Other ports are possible but I am not investing much time on it right now, I need the CM0 port in order to evaluate the idea at its base. It is meant for small devices anyway, CM0 could well be its high end.

BTW just committed the compilable code (not runnable yet, some bits are missing).

Giovanni

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

Re: [FUN] Preliminary results

Postby Giovanni » Sat Jul 07, 2012 1:53 pm

It works :-)

At the second run attempt after just changing a <= in <...

There is a working demo for the STM32F0-Discovery, the final numbers using GCC 4.6.3 with -Os:
Kernel size: 508 bytes.
CM0 port: 136 bytes.
Total OS size: 644 bytes.
Total demo application size: 1831 bytes, inclusive of startup file, vectors, HW initialization, application code.

I think that compiling for the CM3 or MSP430 would make it even smaller because the more efficient instruction sets.

Giovanni

Xamusk
Posts: 81
Joined: Sat Mar 05, 2011 10:47 pm

Re: [FUN] Preliminary results

Postby Xamusk » Fri Jul 13, 2012 1:45 pm

Superb!

I wonder if it would work on small AVRs like the atmega8/88...

User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Location: South Korea
Has thanked: 3 times
Been thanked: 3 times

Re: [FUN] Preliminary results

Postby DeusExMachina » Wed Oct 10, 2012 10:19 am

It looks wonderful, especially with low cost development platforms like msp launchpad or stm32F0-discovery... what about RAM footprint?

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

Re: [FUN] Preliminary results

Postby Giovanni » Wed Oct 10, 2012 10:22 am

It is minimal, a semaphore requires 1-4 bytes depending on the chosen counter type, a thread 8-16 bytes depending on target pointers size.

Stack sizes of course are not affected by the OS.

Giovanni

saraben
Posts: 40
Joined: Thu Sep 20, 2012 12:37 am
Location: Australia

Re: [FUN] Preliminary results

Postby saraben » Wed Jan 09, 2013 7:34 am

Giovanni,
I have had a go at using the Nil code with a hal based on the ChibiOS MSP430 port and included some of the ChibiOS 2.5.1 updates in the port. It works ok.

I have noticed that there are quite a few structural differences between the ChibiOS STM32 and MSP430 hal code.
Would the ChibiOS 2.5.1 template and STM32 version be the best guide at present?
I have some time and have a need for something like Nil for small MSP430s so was considering writing a combined ChibiOS/Nil hal.

The demo code on the MSP430 comes in at: (GCC4.6.3 -Os)
1100 bytes rom
30 bytes OS ram
60 bytes ram / thread which appears a lot but it does include the thread and isr stack.
Perhaps I have imported some ChibiOS numbers in the thread stack size by mistake.
These numbers would mean a minimum 512 bytes of ram for a practical application.

Regards
saraben

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

Re: [FUN] Preliminary results

Postby Giovanni » Wed Jan 09, 2013 8:56 am

Hi,

The STM32 and MSP430 HALs are very different. The MSP430 one targets a specific MCU, the STM32 HAL targets multiple sub-families so it is much more structured. Both are valid examples, it depends what you are aiming to do.

About the HAL, one of the changes I am evaluating is to remove the direct dependency HAL->ChibiOS, the HAL will use the RTOS services through an abstraction layer (close enough to the ChibiOS API anyway in order to not introduce overhead).

The idea is to make the HAL usable with both ChibiOS and Nil and potentially also without RTOS.

Giovanni

wgreiman
Posts: 33
Joined: Sun Oct 23, 2011 3:21 pm
Been thanked: 2 times

Re: [FUN] Preliminary results

Postby wgreiman » Thu Jan 17, 2013 2:30 pm

I have been playing with nil on an Arduino. It appears that nil doesn't do a reschedule in nilSysTimerHandler.

I was running two periodic threads, thread1 with a short period and thread2 with a long period. Thread1 was first in the task table but it was not rescheduled when its sleep period expired.

I added the following lines after the do-while loop in nilSysTimerHandler and it seems to work but may not be the correct solution.

Code: Select all

  nilSysLockFromIsr();
  nilSchRescheduleS(); 
  nilSysUnlockFromIsr();

I am assuming nil is intended to have a fixed priority preemptive scheduler with thread priority determined by position in the task table.


Return to “ChibiOS/NIL”

Who is online

Users browsing this forum: No registered users and 3 guests