pC/OS



To this for beginners at the the fastest to understand real time operating system belongs µC/OS from Jean J. Labrosse. It can administer up to 63 applikationtasks with ever different priorities and belongs to the real time operating systems with the lowest storage demand.
Since the original version from the Embedded System Programming Magazine(1992) FREE is, I deposited these for interrests to download.

Since the company Micrium the source-code distribution license conditions also for the original version from the Embedded Programming Magazine(1992) altered, I can only put a link to the download-side of the magazine here.

Embedded Systems Programming Magazine(1992) - code area




Since is exchanged by direct transfer of pointers in the original version data between the tasks, and consequently no guarantee for the free usability of the sending-buffers after transfer to another task exists and, much important, the recipient a pointer in the data field of another tasks gets (pointer-error / longitudinal mistake / manipulations among others) I altered the mechanisms for Message-Box and Queue accordingly in a way that the data about a kernel-internal Buffer now are handed over to the recipient. This means that the kernel copies to transferring data into an individual buffer and this copies also again itself with transfer to the recipient in the buffer prepared through the recipient. This admittedly entails a higher storage demand for Queue, secures the processes for it most extensive, however (for real-mode) of each other from. Kernel constants were transferred in the CODE-Area for security reasons furthermore. Furthermore I have add pipes, eventgroups and dynamic memory management.
In order to declare these alterations unequivocally, I have the name, ajar at the always bigger nascent original "µC/OS", on pC/OS like "pico-C.." altered.


Special to:  Priority Inversion, the problem and the solutions (actual only in german - sorry!)


To final clarify the status of the pC/OS Kernel based on the µC/OS 1.00,
I picked out the old "V1.00 is FREE" confirmation email from Jean Labrosse.



pCOS_187b.zip
download pC/OS 1.87b (as ZIP)


Releases:

1.00aMessagebox and Queue altered as well as Pipe, Eventgroup and dyn. Memory management added.
* Port for Am188ES created
1.00bRevision info, Tick-counter, Task-Suspension, Task-Delete, History-Table and OS_QueueFrontPost added (Task-Suspension and Task-Delete from 1.09 imports).
Some of bow fix from 1.01 to 1.09 taken over.
1.00cAcceleration of the Pipe, with taskswitch on reason of the data transfer and if Pipe become copy the data of the sending-buffer empty in the receiver-buffer.
Implementation of a wait for stations, OS_..... Post.
Not implements attendants for stations and recipients by means of OS_NO_SUSP.
To aim, of Queue and Pipe, specifically: Pointers on Kernel-buffer, revises.
1.00dcorrect implementation "timeout" in OS_....Post functions and OS_QueueClear added.
1.00eAdaptation the Task-Initialistion and some parameter to the utilization of the ┬ÁC/OS-I Port's.
OS_QueueInfo and OS_PipeInfo added.
1.00fBug fix within the Event-Groups.
OS_SemAccept added.
1.00gDual-Source for MSC-8.00 und Keil-C51 generated. OS_CFG implemented. Bugfix in Semaphores.
* Port for 8051 added
1.00hMUTEXes added, Eventgruppen correct implemented and code-cleanup. Cleanup of the ports.
* Port for Rabbit 2000/3000 added
* Port for Philips-XA added
1.40aName on pC/OS altered and revision number revises, some C-fixes.
* Port for ATMega128 added
* Port for AT91SAM7Sxx added
1.41aImplementation of OS_STK_TYPE for processor conform stack incl. update of all existing ports.
Keil-version of AT91SAM7Sxx-port (instable) added
1.50cComplete update to U08..U32 types.
Implementation of OS_PACKED, OS_PACKED_ATTR and align(x)-corrections.
Small correction in OS_TaskSuspend()
* Port for LPC214x added
* Port for LPC236x added
* Port for STR71x added
1.52bSplit MIN_PRIO and MAX_TASKS to reduce RAM on smaller max-tasks, using "NULL" as pointer, add unique task-ID for other modules on use of prio-changes and to reduce RAM on this modules.
* Port for Cortex-M3 Luminary LM3S811 added
1.60cadd temporary reg-holder for disabling/enabling interrupts inside of a ISR as protection again neested ints, if this is undesirable
* Port for Cortex-M3 STM32 added
1.61athe memory-manager now works alltimes MPU-spezific aligned
1.65btimer-service implemented, his timers can run periodical or run-once.
some new API-functiones added
1.66csome checks added in TIMERS, OS_TimerGetState() and OS_TimerGetRemain() implemented
1.67areducing RAM consumption on prio-tables of IPC-recources (SEM/EVG/MUX/Queue/Pipe/..)
* Port for PIC32 added
* Port for MSP430 added
1.68aOS_EvgPendAbbort() added
* Port for AVR32 added
1.70boptional debug stack-end check added, kernel configuration restructured
1.71aadditional optional stack-fill to stack-end check feature added
1.80csome fixes in all ...Abbort() functions, some additional checks for "mutex in use", OS_TaskGetID() and OS_TaskGetStatus() added, with new OS_TaskDestroy() now tasks - waiting on a resource - can deleted too, source file splitted for better handling
* Port for ATMega32 added
1.81bthrough an extension in the optional function OS_TaskDestroy() a mutex protected recourse can now be re-initialized, even if a user management included based on the unique task ID (for example a filesystem)
1.82aOS_TaskDestroy() renamed to OS_TaskIdDestroy(), OS_TaskGetPrio(), OS_TimeDelayIdResume(), OS_TaskIdDelete(), OS_TaskIdGetStatus(), OS_TaskIdSyspend() and OS_TaskIdResume() added plus some additional checks for prio and/or id
1.83asmall fix for OS_TaskIdDestroy() in OSIntExit(), if the current running task destroyed by an ISR
* Port for Cortex-M0 LPC11xx added
* Port for Cortex-M3 LPC13xx added
* Port for Cortex-M3 LPC17xx added
* Port for Cortex-M3 AT91SAM3xxx added
1.83bmini fix in OSTCBInit(..) for missing compiler switch
1.84achange events param in eventgroups to pointer for better handling of OR mode (with return), small fix in Pipe for fast data switching
* Port for Cortex-M4 STM32F4xx added
1.85bcorrection in eventgroups for multiple pending tasks on one eventgroup
1.86aOS_ID_SELF added for OS_TaskIdDelete() and OS_TaskGetPrio()
* Port for Cortex-M0 SAMD21 added
1.87ban interrupt and during sheduling is switched off a sender can't use the fast mode on OS_Pipe...Post since data source can't be guarantied
* Ports for Cortex-M23 and Cortex-M33 (ARMv8M baseline & mainline) added (w/o active TZ support)
* Port for Cortex-M3 TI Luminary LM3S9B92 added
* Port for Cortex-M0 Nuvoton NUC123 added
* Port for Cortex-M0 Freescale MKL25Z128 added
* Port for Cortex-M0 Freescale MKL26Z64 added
* Port for Cortex-M4 Freescale MK20DX256 added
* Port for Cortex-M0 Infineon XMC1100 added
* Ports for STM32F0xx..7xx renewed
* Port for RISC-V SiFive FE310 added


With waits for "OS_.... Post" and "OS_.... Pend" - functions heeding is that can be done with a wait or even suspension out with a call of a transmitter-/receiver functions from an ISR NEVER, since the ISR stops this, and consequently nothing more runs. An examination of this condition is integrated.

known bugs:
If a task with lower priority waits for a recource, and a task with higher priority this recource places, so the asleep Task is put into the ready-state. Since the task with higher priority further-runs, this cannot finish reading again the same recource since the lower task 'prematurely' comes with implementation with the return-code OS_TIMEOUT back otherwise.



Kernelservices of the pC/OS version 1.87b (abbreviation)
This here presented function overview only serves as short overview.
For detailed information, you please look in Reference-Manual about pC/OS.


Task-Control:Description
OS_InitInitialization of the kernel
OS_StartBegin the kernelservices
OS_TaskCreateGenerating of a task
OS_ChangePrioAlteration of the priority of the active task
OS_TaskChangePrioAlteration of the priority of a active/ready task
OS_TaskDeleteDeletion of a active/ready task
OS_TaskIdDeleteDeletion of a active/ready task via unique ID
OS_TaskGetStatusreturns the current status of a task
OS_TaskIdGetStatusreturns the current status of a task via unique ID
OS_TaskGetIDreturns the unique ID of a task
OS_TaskGetPrioreturns the priority of a task
OS_TaskIdDestroyDeletion of a tasks via unique ID, even if it waits for an IPC or a mutex has locked & release all memory allocations
OS_TaskSuspendSuspending of a task
OS_TaskIdSuspendSuspending of a task via unique ID
OS_TaskResumeReactivation of a suspended task
OS_TaskIdResumeReactivation of a suspended task via unique ID
OS_TimeDlyPut current task for certain time sleeps
OS_TimeDlyResumeReactivation of an asleep task before course of the put in time
OS_TimeDlyIdResumeReactivation of an asleep task via unique ID before course of the put in time
OS_LockIt suppresses of the Sheduler (no taskswitch)
OS_UnlockIn again circuit of the Sheduler (taskswitch at event or time)
OS_GetRevIt returns pointer to kernel revision



Dynamic-Memory:Description
OS_MemoryInitGenerates of the memory pool
OS_MemAllocAllocation of memory
OS_MemFreeRelease of allocated memory
OS_MemFreeSizeIt returns the amount of free memory



Mailboxes:Description
OS_MboxInitInitialisation of a mailbox
OS_MboxPostSend data to task with higher priority recipients of this mailbox
OS_MboxPostAbbortAbborts waiting of a sending task (highest waiting prio) onto a mailbox
OS_MboxPendWait for data from a mailbox
OS_MboxPendAbbortAbborts waiting of a receiving task (highest waiting prio) onto a mailbox



Queues:Description
OS_QueueInitInitialsation of a queue
OS_QueueInfoInformation about a queue catches up with
OS_QueuePostSend data into a queue
OS_QueueFrontPostSend data to the beginning of a queue
OS_QueuePostAbbortAbborts waiting of a sending task (highest waiting prio) onto a queue
OS_QueuePendWait for data from a queue
OS_QueuePendAbbortAbborts waiting of a receiving task (highest waiting prio) onto a queue
OS_QueueClearDelete all data in a queue



Pipes:Description
OS_PipeInitInitialisation of a pipe
OS_PipeInfoInformation about a pipe catches up with
OS_PipePostSend data into a pipe
OS_PipeFrontPostSend data to the beginning of a pipe
OS_PipePostAbbortAbborts waiting of a sending task (highest waiting prio) onto a pipe
OS_PipePendWait for data from a pipe
OS_PipePendAbbortAbborts waiting of a receiving task (highest waiting prio) onto a pipe
OS_PipeClearDelete all data in a pipe



Semaphores:Description
OS_SemInitInitalisation of a semaphore
OS_SemAcceptwait for event and returns number
OS_SemPostRelease of a busy semaphores / places event
OS_SemPendCover one semaphore / waits on event
OS_SemPendAbbortCover one semaphore / waits on event
OS_SemClearClear the semaphore-counter



Mutexes:Description
OS_MutexCreateGenerating of a mutex
OS_MutexPostRelease of a mutex
OS_MutexPendCover the mutex
OS_MutexPendAbbortAbborts waiting of a task (highest waiting prio) onto a mutex



Event-Groups:Description
OS_EvgInitInitialisation of a Eventgroup
OS_EvgPostPlace one/many events of an Evengroup
OS_EvgPendWait for arriving an or several events of an Eventgroup
OS_EvgPendAbbortAbborts waiting of a task (highest waiting prio) onto a Eventgroup



Timer-Service:Description
OS_TimerCreateGenerating of a Timer
OS_TimerDeleteDeleting of a generated Timer
OS_TimerStart(Re-)Start of a generated Timer
OS_TimerStopStop of a generated Timer
OS_TimerGetStatereturns the status of a generated Timer
OS_TimerGetRemainreturns the remaining time of a running Timer



System-Ticks:Description
OS_TimeSetSet ticker to value
OS_TimeGetreturns current ticker-value



Interrupts:Description
OS_IntEnterRegistration of a called ISR
OS_IntExitEnd of a called ISR



History:Description
OS_HistoryPostWrite entry in History
OS_HistoryReadFirst History-entry give and delete this in the table



Error-Codes:

Name

Decimal_Value

OS_SUCCESS / OS_NO_ERR

0

OS_TIMEOUT

10

OS_MBOX_FULL

20

OS_MBOX_NODATA

21

OS_Q_FULL

30

OS_Q_NODATA

31

OS_Q_CLEAR

32

OS_PRIO_EXIST

40

OS_TASK_NOT_EXIST

41

OS_SEM_ERR

50

OS_SEM_NODATA

51

OS_SEM_OVF

52

OS_MUX_ERR

55

OS_MUX_NOACC

56

OS_MUX_USED

57

OS_P_FULL

60

OS_P_NODATA

61

OS_P_CLEAR

62

OS_P_LEN_ERR

63

OS_MEM_ERR

70

OS_MEM_OVF

71

OS_EVG_ERR

80

OS_EVG_NOE

81

OS_HIS_END

90

OS_SUSPEND_IDLE

100

OS_PRIO_INVALID

101

OS_TIME_NOT_DLY

102

OS_TASK_SUSP_PRIO

103

OS_TASK_NOT_SUSP

104

OS_TASK_NOT_RDY

105

OS_TMR_NO_TIME

106

OS_TMR_NOT_EXIST

107

OS_TMR_EXIST

108




Tip to ASM-ISR's:

To integrate assembler-ISR's in to pC/OS manually, following start code must be implemented with in jump into the ISR: (example x86)

EXTRN C OSIntEnter : NEAR EXTRN C OSIntExit : NEAR ... ISR: pusha ; save all used register push es call OSIntEnter ; C-function to register INT-level ...

und am Ende der ISR:

... call OSIntExit ; C-function to unregister INT-Level ; and perform a context-switch is needed pop es ; restore all used register popa iret ; return