Jump to content
Reynard

Binary Semaphores

Recommended Posts

Dave and Pavel,

 

Having problems with binary semaphore being set when powering up.

 

The binary semaphore storage byte '___sema' does not appear to get cleared during SysInit().

 

This byte is also not contained with the Sheduler structure. I am sure there is a good reason for that.

 

If I clear this byte within my application (after SysInit() call) all works OK.

 

Should I patch Novo.c or do you have a preferred solution.

 

Cheers

 

Reynard

 

Share this post


Link to post
Share on other sites

I was hoping if somebody could offer some design advice regarding the use case for binary semaphores.

 

In a situation where you have a hardware interrupt eg. rx buffer full and you want to signal to another thread to parse the data packet, is there any advantage of using a binary semaphore instead of simply putting the parsing thread asleep and waking it up from the interrupt? Both seem to work without any noticeable differences but since I do this kind of thing so often I just wanted to make sure there wasnt a reason to use one technique over the other. Thanks

Share this post


Link to post
Share on other sites

I was hoping if somebody could offer some design advice regarding the use case for binary semaphores. In a situation where you have a hardware interrupt eg. rx buffer full and you want to signal to another thread to parse the data packet, is there any advantage of using a binary semaphore instead of simply putting the parsing thread asleep and waking it up from the interrupt? Both seem to work without any noticeable differences but since I do this kind of thing so often I just wanted to make sure there wasnt a reason to use one technique over the other. Thanks

Good question.

If more than one task or thread of execution wants to share a resource then semaphores are a much better fit.

If only two tasks or threads want to share a resource, and one of them wants to do the foreground processing, then waking and sleeping is probably much neater.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×