# Interrupt and Task Synchronization Issue when using Semaphore.

**URL:** <https://forums.freertos.org/t/interrupt-and-task-synchronization-issue-when-using-semaphore/5841>\
**Category:** Kernel\
**Created:** [March 17, 2016, 5:32pm UTC](https://forums.freertos.org/t/interrupt-and-task-synchronization-issue-when-using-semaphore/5841 "2016-03-17T17:32:26Z")\
**Posts on this page:** 2\
**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:** [March 17, 2016, 5:32pm UTC](https://forums.freertos.org/t/interrupt-and-task-synchronization-issue-when-using-semaphore/5841/1 "2016-03-17T17:32:26Z")

</div>

**[naveenkumarbece](https://sourceforge.net/u/naveenkumarbece/)** wrote on [Thursday, March 17, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/032b958c/#b438):

Interrupt and Task Synchronization Issue when using Semaphore.

Scenario:  
I have one ISR and one FreeRTOS Task.  
The ISR copies the data into queue whenever the ISR occurs. and  
FreeRTOS Task copies the data whenever there are some data in the queue.  
It is synchronsied using Semahpores.

If the interrupt calls evvery 100/10 ms, everything fine.  
if the interrupt calls every 1ms/100m micro seconds, the FreeRTOS task is not  
reading anything from the FIFO and the buffer overflows at the ISR Side.

Since, the ISR takes the Semaphore always, it seems that the FreeRTOS  
is not copying the data and in the blocked or suspended mode.

Any idea how to handle this scenario?  
any other way other than Semaphore?

ISR  
{  
Semaphore takefrom ISR();  
// Copies data into static queue  
Semaphore givefrom ISR();

}

FreeRTOS Task  
{   
Semaphore take(port\_MaxDelay);  
// Receives data from the static queue  
Semaphore give();  
}

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [March 18, 2016, 10:31am UTC](https://forums.freertos.org/t/interrupt-and-task-synchronization-issue-when-using-semaphore/5841/2 "2016-03-18T10:31:55Z")

</div>

**[hs2sf](https://sourceforge.net/u/hs2sf/)** wrote on [Friday, March 18, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/032b958c/#dd92):

You should try to reduce the interrupt rate (e.g. add an ISR private buffer to collect some more date before putting it into the shared, sem.protected Q).  
I guess your system is just overloaded when using the higher interrupt rate ie. is busy with ISR processing and there is no chance for the task to get into running state.
