Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Counting Semaphore! Please help me to test.

Posted by Dmitriy A. Cherepanov on November 19, 2007
##############Counting semaphores.#######################

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.

http://dima.udmlink.ru/semaphore.zip

I hope Richard Barry will take this code to his OS kernel.

Anyway I will use It in my applications.

And that's why I asked Richard and other people who want to have another implementation to test this code.

I used OpenWatcom1.7a compiler and WindowsXP for testing

semtest.c is working fine.

All you need is to put this file it in your freertos directory and replace headers.
Just replace
#include "semphr.h"
on
#include "semphore.h"

Also I will be glad if you test my suggestions on memory
at heep.c

I wish to receive suggestions bugs and etc on my box

dmitrycherepanv at users.sourceforge.net


Regards,
Dmitry.

RE: Counting Semaphore! Please help me to test.

Posted by Richard on November 19, 2007
Hi - thanks again for your contribution.

>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

I will reply to your other post on this.

Thanks again and regards.

RE: Counting Semaphore! Please help me to tes

Posted by Dmitriy A. Cherepanov on November 19, 2007
>It is great that OpenWatcom is not open source, and still being maintained.
OpenWatcom is not open source ???????????

As far as I know OpenWatcom is open source now.

I don't know that license exacly but All new versions is maintained with opensource community.

I think it is great that it is still being maintained.
I have heard But there is problems with the leadership of the project

RE: Counting Semaphore! Please help me to tes

Posted by Dmitriy A. Cherepanov on November 19, 2007
>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

sizeof (queue) = 9*2+5+4*2 - 31 bytes
sizeof (Semaphore) = 9

the difference is - 22 bytes

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. :-)






RE: Counting Semaphore! Please help me to tes

Posted by Richard on November 20, 2007
>It is great that OpenWatcom is not open source, and still being maintained.

That was meant to say:

"It is great that OpenWatcom is *now* open source".

Typo.

Regards.

RE: Counting Semaphore! Please help me to test.

Posted by Borut on November 20, 2007
Hello Dmitry,

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 :)

Regards

RE: Counting Semaphore! Please help me to tes

Posted by Dmitriy on November 20, 2007
I have found some bugs I my sources
Now I am trying to fix it.

RE: Counting Semaphore! Please help me to tes

Posted by Dmitriy on November 20, 2007
Bugs have fixed You can use It

RE: Counting Semaphore! Please help me to tes

Posted by Dmitriy on November 28, 2007
AS I see there is nobody who have an interest to the counting semaphores.

I have test them on Open Watcom 1.7a compiler. And it is working well.

In spite of that I am placing a new link where you can find the sources. (I have fixed some little bugs).

http://freertos.narod.ru/semaphore.zip

May be somebody will test them and use for himself and also send me a message.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner