# Semaphore's

**URL:** <https://forum.sierrawireless.com/t/semaphores/135>\
**Category:** Open AT\
**Created:** [November 15, 2005, 11:03am UTC](https://forum.sierrawireless.com/t/semaphores/135 "2005-11-15T11:03:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dannydgza](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@dannydgza](https://forum.sierrawireless.com/u/dannydgza)\
**Post date:** [November 15, 2005, 11:03am UTC](https://forum.sierrawireless.com/t/semaphores/135/1 "2005-11-15T11:03:06Z")

</div>

Hi

Is it possible for one callback to interrupt another calback i.e. timer callback function being interrupted by a uart callback function (which is asynchronous) ??

If the answer is YES to the above is it possible to protect shared variables from being incorrectly updated. In PC programming there are “enter critical section/leave critical section” functions that can be used to protect variables in a multi-task OS enviroment.

Kind Regards,  
Danny

---

<div class="post-metadata">

**Author:** ![jan](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@jan](https://forum.sierrawireless.com/u/jan)\
**Post date:** [November 15, 2005, 11:10am UTC](https://forum.sierrawireless.com/t/semaphores/135/2 "2005-11-15T11:10:29Z")

</div>

Hi Danny,

I am pretty sure it is not possible!

It has been discussed in other places here and I have also made the experience that while a call back function does not return, the whole system is blocked. (And no oher call back functions are called…)

So, you should be safe without semaphore or similar constructs!

Best Regards,  
Jan

---

<div class="post-metadata">

**Author:** ![sladjan](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@sladjan](https://forum.sierrawireless.com/u/sladjan)\
**Post date:** [January 13, 2006, 5:40pm UTC](https://forum.sierrawireless.com/t/semaphores/135/3 "2006-01-13T17:40:09Z")

</div>

Hi,

Yes, while a call back function does not return the whole system is blocked. You must know that you should not wait more thant 4 or 4.5 seconds in a call back function because a wavecom WachDog timer will reboot the whole system.

Regards,  
Sladjan.

---

<div class="post-metadata">

**Author:** ![daniel.alvarez](https://avatars.discourse-cdn.com/v4/letter/d/b782af/32.png) [@daniel.alvarez](https://forum.sierrawireless.com/u/daniel.alvarez)\
**Post date:** [January 16, 2006, 9:08am UTC](https://forum.sierrawireless.com/t/semaphores/135/4 "2006-01-16T09:08:42Z")

</div>

Hi,

well i suppose the same is applied to non-callback functions. For example, if my adl\_main calls a function named UART1Open()  
and this function for example calls the adl\_fcmSubscribe and then waits activelly for a flag to be changed when the Control Handler is called with the ADL\_FCM\_EVENT\_FLOW\_OPENED, then this won’t work because the callback won’t be called till my UART1Open function returns.  
Is this correct?

If it is, then there’s no chance to make a UARTOpen function which receives for example the baudrate, the number of the UART to be opened, flow control, … and returns 1 when all the actions related to its setup are performed and the flow is ready to use.

Best regards,  
Daniel

---

<div class="post-metadata">

**Author:** ![jan](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@jan](https://forum.sierrawireless.com/u/jan)\
**Post date:** [January 16, 2006, 9:20am UTC](https://forum.sierrawireless.com/t/semaphores/135/5 "2006-01-16T09:20:05Z")

</div>

Hi Daniel,

it is exactly like that. You cannot do it this way! Your application needs to return control flow to the operating system so that it can do its processing.

In this system you cannot do a busy wait any place in the code… The condition you wait for will not change. Your application only has a single thread and the operating system requires the internal application to return control…

Best Regards,  
Jan

---

<div class="post-metadata">

**Author:** ![daniel.alvarez](https://avatars.discourse-cdn.com/v4/letter/d/b782af/32.png) [@daniel.alvarez](https://forum.sierrawireless.com/u/daniel.alvarez)\
**Post date:** [January 16, 2006, 9:28am UTC](https://forum.sierrawireless.com/t/semaphores/135/6 "2006-01-16T09:28:02Z")

</div>

Thanks jan for the reply,

so this is the Event World ! 😃 It ain’t easy then to encapsulate things so that the code looks ‘platform independent’.

Cheers  
Daniel
