====== Introduction ======

The operating system module (acronym: os) should provide a unified interface to the basic functions of an operating system, particularly real-time operating system (RTOS). We're targeting basically the multithreading support.
The main OS functions are:
  * threads
  * semaphores
  * mutexes

====== OS Support ======

The os module should support at least these operating systems:
  * FreeRTOS
  * uC/OS-II and uC/OS-III
  * CoOS
  * Keil RTX
  * CMSIS-RTOS interface
  * Linux (pthreads)
  * Windows (win32)

Others interesting:
  * NuttX
====== Known issues ======

===== Thread function declaration =====

Various operating systems expect different declaration of the thread implementation function. The general shape is:

<code>
result threadFunc(someType* pointer);
</code>

In small RTOSes the result tends to be void. In bigger OSes the result is usually int or void*.
The task argument is usually a pointer to void, however there is some inconsistency about the actual type.

Now in order to unify the way threads are implemented, the thread function declaration should be fixed. This implies that in case of some OSes there may be some wrapper function required to serve as a thread and call the unified thread function. These wrappers cost less in bigger OSes, so in favor of the small ones, the thread implementation function should probably be fixed like this:

<code>
void threadFunc(void* arg);
</code>

===== How scheduler is invoked and when the thread is started =====

The big difference between big OSes (let's say linux) and small ones (let's say FreeRTOS) is how the application and scheduler interact. In case of a linux operating system the scheduler invokes the application, and when application is creating a thread - this thread is started immediately and that's considered as normal behavior.
On the other hand, in a microcontroller the RTOS is usually started by an implicit call to a system API function, and the threads may already be created. 
The source of inconsistency here is then:
  * whether the call to start the OS is needed or not
  * whether the threads should by default start suspended or not

===== Useful resources =====

[[http://www.embedded.com/design/operating-systems/4425751/Comparing-microcontroller-real-time-operating-systems]]