10 years, 4 months ago.

RTOS questions

Hi

Im fairly new to C but have been programming for quite a while.

With regards to the two header files, #include "rtos.h" and #include "cmsis_os.h". What is the main difference between the 2 systems and is one preferable to use to the other ?

I have downloaded the cmsis documents from Keil/ARM and is reading that

Thanks

3 Answers

K P
poster
10 years, 4 months ago.

Okay, but looking the mbed web pages for both options, the basic samples (cmsis_rtos_basic - main.cpp and rtos_basic - main.cpp) shows quite different OS terminology used for blinking a LED.

So does the cmsis_os.h have the RTX behind it or is it purely a API ?

There has to be a difference (significant ?) as no-one will maintain 2 versions of nearly the same SW ?

Thanks

K

Accepted Answer

As I said, mbed RTOS is just a shell around cmsis RTOS (which I guess Neil is correct is a standard API for the underlying RTX).

If you see the mbed RTOS code: http://mbed.org/users/mbed_official/code/mbed-rtos/, the top folder is the actual mbed part. Check some of the files in it, they are almost empty and only have a few simple functions, calling the actual code in the RTX folder.

posted by Erik - 10 Jan 2014

Okay, I kind of got that.

Have looked through a bunch of the files in rtos.h So what are the advantages of using the mbed rtos.h versus the cmsis.h ?

posted by K P 10 Jan 2014

rtos.h just provides easy to use C++ classes that wrap around the C API so you don't have to use it directly. It's just easier to use. Kind of like DigitalIn or DigitalOut, they're just classes that wrap around the actual C code for controlling pins for the purpose of making it easier to use.

posted by Neil Thiessen 10 Jan 2014
10 years, 4 months ago.

Did you already find: http://mbed.org/handbook/RTOS and http://mbed.org/handbook/CMSIS-RTOS?

cmsis_os is the default RTOS from I guess ARM or some other group. rtos.h is from the official mbed RTOS, which is built upon cmsis_os (which is also automatically included when you include the mbed RTOS), and allows you to easily use the cmsis RTOS using C++ functions.

If needed you can also combine them. For example here http://mbed.org/users/Sissors/code/SimpleDMA/file/d9f46ef80e20/SimpleDMA.h (somewhere at the bottom the RTOS stuff is), I needed to give a thread a signal, however I do not know there which thread it is, and I do need to know the thread to give it a signal in the mbed RTOS. However in the cmsis RTOS code below it I only need to know the thread ID, and the thread ID I could easily get. So there I use:

osSignalSet(id, 0x1);  

While everywhere else the standard mbed RTOS API is used.

10 years, 4 months ago.

The way I understand it is CMSIS-RTOS is just an API for RTOS', not an actual RTOS. The underlying RTOS in this case is RTX. Therefore, by this logic if you used the C API, your code would be more portable to other CMSIS-RTOS compliant RTOS'. For instance, you could theoretically design a project around a CMSIS-RTOS version of FreeRTOS, and switch to something like RTX later on with minimal code changes, if any. This is how I've come to understand it anyway, somebody tell me if this is incorrect.