954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Using a Semaphore in Reentrant function

Can anyone tell me whether it is allowed to use a Semaphore in a Reentrant function.

venuaccha
Newbie Poster
9 posts since May 2007
Reputation Points: 29
Solved Threads: 0
 

Do you mean 'will the compiler complain' - no.
'Is it a good idea' - Again, probably not.

Reentrant functions should have all of their data passed to them as arguments, and not use global data structures. Semaphores are traffic cops for access to global objects or shared objects.

This sounds like a threads design problem. What are you trying to do?

jim mcnamara
Junior Poster
180 posts since May 2004
Reputation Points: 62
Solved Threads: 10
 

I got the answer from below link.
http://www.unet.univie.ac.at/aix/aixprggd/genprogc/writing_reentrant_thread_safe_code.htm#o8Nfj357manu



Do you mean 'will the compiler complain' - no.
'Is it a good idea' - Again, probably not.

Reentrant functions should have all of their data passed to them as arguments, and not use global data structures. Semaphores are traffic cops for access to global objects or shared objects.

This sounds like a threads design problem. What are you trying to do?

venuaccha
Newbie Poster
9 posts since May 2007
Reputation Points: 29
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You