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

Recommended Answers

All 2 Replies

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?

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.