Then I start to use FreeRTOS. I thought that the first and simplest thing that
OS must have is an semaphore. And I was surprised about semaphores in
FreeRTOS. Actually there is no semaphore there is only a macroses and binary semaphores.
Also I saw that many people asked about counting semaphores. And so
I decided to look how it works and why there is only queue in OS and how
semaphores can be written.
And finally I tried to write semaphore. Here is my semaphore code for the FreeRTOS kernel.
>Then I start to use FreeRTOS. I thought that the first and simplest thing that
>OS must have is an semaphore. And I was surprised about semaphores in
>FreeRTOS. Actually there is no semaphore there is only a macroses and binary semaphores.
One of the primary design goals for FreeRTOS.org is to keep the memory footprint to a minimum. To this end, the queue was developed to include both the communications mechanism and the event control data (many RTOSes have these as separate data structures), providing a generic intertask communication mechanism that can be used for many purposes. This is why both binary semaphores and mutexes are built as macros on top of the queue primitive. Binary semaphores add no extra code to the image size, and mutexes only a tiny amount of code.
Counting semaphores are used less often in small to medium sized embedded applications. Normally in FreeRTOS.org they are implemented by simply extending the binary semaphore implementation so that there is more than one space in the underlying queue. Were you the person we were discussing this with on this forum a month or two back?
>
>Also I saw that many people asked about counting semaphores. And so
>I decided to look how it works and why there is only queue in OS and how
>semaphores can be written.
>
>And finally I tried to write semaphore. Here is my semaphore code for the FreeRTOS kernel.
>
>http://dima.udmlink.ru/semaphore.zip
I have downloaded your code to take a look at your implementation. I’m on the road at the moment so a bit out of communication so it might be a day or two.
>I used OpenWatcom1.7a compiler and WindowsXP for testing
This is a very convenient setup for testing. I use it myself a lot. It is great that OpenWatcom is not open source, and still being maintained. The only thing to watch out for is that stepping the debugger from within a critical section temporarily enables interrupts, which can cause lots of problems.
>Also I will be glad if you test my suggestions on memory
>at heep.c
>One of the primary design goals for FreeRTOS.org is to keep the memory footprint to a minimum.
Then I looked for Operating System for my AtMega128
I found about 5 operating systems with opensourse licenses. But they are not so RealTime As FreeRTOS and not so well documented. That is why I have choosen FreeRTOS.
Some of them are not supported tasks with their own stack (only CoRoutines) and that is why they are not preemptive.
That is why they use less RAM than FreeRTOS.
Well, I can say that FreeRTOS use very little amount of RAM and ROM also.
There is no comparison between such monster Linux and FreeRTOS.
>Counting semaphores are used less often in small to medium sized embedded applications.
>Normally in FreeRTOS.org they are implemented by simply extending the binary semaphore implementation
>so that there is more than one space in the underlying queue.
>Were you the person we were discussing this with on this forum a month or two back?
I agree with you that there is less size of Code but look at my
8bit RISC ATMEGA128 128k of ROM and only 4k of RAM on board
I would prefer to increase the size of freeRTOS twice with even 32k of ROM
than lost 22 bytes on every semaphore
For example I have about 10 semaphores in my project - 220 bytes
configMINIMAL_STACK_SIZE = 86 in atmega323 - 3 new tasks
Also there is Atmega chips with 512 and 1024 and 2048 bytes of RAM.
And on other low cost chips ROM is much bigger than RAM I suppose
Certainly may be there is a chips only with RAM like ancient Intel i8080 with his 64k RAM
Then I was young I played games with such computer.
A have to load games from tape recorder for 5 or 10 minutes after every reset.
That was fun.
it is great that you have done this counting semaphore code (i just download it and will test it ASAP). I was asking about this issue a few months ago and also for event flags. I must say i used counting semaphores a lot with my previous RTOS so I was also wondering why there aren’t any here. So Richard kindly suggested how to implement them and I did and used that implementation since then. But event flags are still one feature that would be very helpfull