Jump to content


Photo

Binary Semaphores


2 replies to this topic

#1 Reynard

Reynard

    Maniac

  • EstablishedMember
  • PipPipPipPip
  • 656 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Archery - target and field

Posted 08 December 2015 - 06:58 PM

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

 



#2 Eleriader

Eleriader

    Newbrie

  • Members
  • 1 posts
  • Gender:Female
  • Location:144144
  • Interests:EleriaderTH

Posted 11 December 2016 - 06:28 AM

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

#3 Dave

Dave

    Super Maniac

  • Administrators
  • PipPipPipPipPip
  • 2,091 posts
  • Gender:Male
  • Location:UK
  • Interests:How things work, Electronics, Software, Cycling.

Posted 11 December 2016 - 08:33 PM

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



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users