# Semaphore Execution time

**URL:** <https://forums.freertos.org/t/semaphore-execution-time/5369>\
**Category:** Kernel\
**Created:** [October 28, 2015, 4:58am UTC](https://forums.freertos.org/t/semaphore-execution-time/5369 "2015-10-28T04:58:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 28, 2015, 4:58am UTC](https://forums.freertos.org/t/semaphore-execution-time/5369/1 "2015-10-28T04:58:17Z")

</div>

**[sindhukrishnan](https://sourceforge.net/u/sindhukrishnan/)** wrote on [Wednesday, October 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/ecab6aea/#827e):

Hello FreeRTOS Team

I use TMS570LC4357 HDK with FreeRTOS, HALCoGen v4.5.1 for Code generation and CCSv6 as IDE.  
I use Counting Semaphore to handle an Interrupt task. I’ve configured the Semaphore queue size as 100 and the waiting time for Semaphore as 1 tick.

When I run the code, the time taken between _xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );_ inside the ISR and the _if(xSemaphoreTake( xSemaphore, 0x01 ) == pdTRUE)_ inside the ISR Handler is 880ms. Also I face a Jitter in the task that runs cyclically every 1ms. Does Counting Semaphore execution time take 880ms?

Which of these consume the least exection time in event handling  
i) Counting Semaphore  
ii) Binary Semaphore  
iii) Event Group ?

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [October 28, 2015, 8:52am UTC](https://forums.freertos.org/t/semaphore-execution-time/5369/2 "2015-10-28T08:52:18Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, October 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/ecab6aea/#7c97):

> When I run the code, the time taken between xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken ); inside the ISR and the if(xSemaphoreTake( xSemaphore, 0x01 ) == pdTRUE) inside the ISR Handler is 880ms

That sounds exceptionally long.

Q1 Are you using the xHigherPriorityTaskWoken parameter to request a context switch inside the ISR?

Q2 Does the task you are unblocking have a priority above the priority of the currently running task (the task the ISR interrupted)?

> Which of these consume the least exection time in event handling

Actually the least amount of time will be a direct to task notification, which you can use in exactly the same way as either a binary or counting semaphore. Look at the example code on the following page:

> **[vTaskNotifyGiveFromISR() RTOS task notification API documentation](https://www.freertos.org/vTaskNotifyGiveFromISR.html)**
>
> Give a Real Time Operating System (RTOS) notification from an interrupt

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 28, 2015, 9:35am UTC](https://forums.freertos.org/t/semaphore-execution-time/5369/3 "2015-10-28T09:35:49Z")

</div>

**[sindhukrishnan](https://sourceforge.net/u/sindhukrishnan/)** wrote on [Wednesday, October 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/ecab6aea/#f8f0):

For Q1, yes I did use xHigherPriorityTaskWoken parameter. Is NULL sufficient for use there?  
For Q2, the Unblocking task has the highest priority of all tasks.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [October 28, 2015, 9:55am UTC](https://forums.freertos.org/t/semaphore-execution-time/5369/4 "2015-10-28T09:55:58Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, October 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/ecab6aea/#bebb):

> yes I did use xHigherPriorityTaskWoken parameter. Is NULL sufficient for use there

No - if you pass in NULL then it means you are not using it. Please read the documentation for the port you are using, and the API documentation for the functions you are using in the interrupts.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 28, 2015, 10:02am UTC](https://forums.freertos.org/t/semaphore-execution-time/5369/5 "2015-10-28T10:02:35Z")

</div>

**[sindhukrishnan](https://sourceforge.net/u/sindhukrishnan/)** wrote on [Wednesday, October 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/ecab6aea/#6c53):

I use Cortex R5F (TMS570LC4357) and I donot find the documentation for this particular port

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [October 28, 2015, 10:15am UTC](https://forums.freertos.org/t/semaphore-execution-time/5369/6 "2015-10-28T10:15:41Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, October 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/ecab6aea/#6c53/bd5f):

The quick start guide shows you how to locate the documentation:  
[http://www.freertos.org/FreeRTOS-quick-start-guide.html](http://www.freertos.org/FreeRTOS-quick-start-guide.html)

although I believe the code TI are shipping is slightly different to  
that in the FreeRTOS zip file download.

The web server seems very slow at the moment…hopefully that is a  
temporary glitch.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 28, 2015, 11:54am UTC](https://forums.freertos.org/t/semaphore-execution-time/5369/7 "2015-10-28T11:54:30Z")

</div>

**[sindhukrishnan](https://sourceforge.net/u/sindhukrishnan/)** wrote on [Wednesday, October 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/ecab6aea/#9cb9):

I find only Cortex R4F port available in Supported devices in the above link. Will FreeRTOS provide port for Cortex R5F in the near future?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 28, 2015, 11:56am UTC](https://forums.freertos.org/t/semaphore-execution-time/5369/8 "2015-10-28T11:56:02Z")

</div>

**[sindhukrishnan](https://sourceforge.net/u/sindhukrishnan/)** wrote on [Wednesday, October 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/ecab6aea/#159c):

May I know what are the possible conditions that causes Scheduler to Suspend itself when running FreeRTOS code ?

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [October 28, 2015, 12:01pm UTC](https://forums.freertos.org/t/semaphore-execution-time/5369/9 "2015-10-28T12:01:32Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, October 28, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/ecab6aea/#9cb9/d7b8):

I’m not sure that, from the perspective of the RTOS, there is a  
difference between the two  
([http://www.arm.com/products/processors/cortex-r/cortex-r5.php](http://www.arm.com/products/processors/cortex-r/cortex-r5.php)). Would  
you disagree? I know WITTENSTEIN have supplied OpenRTOS for both.

Regards.
