While checking Mutex unlock codes around, I found some that add 1 into the mutex variable instead of setting it to “1” directly. Is there any pros/cons of this?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I wonder if it is possible that you are refereeing to the difference between mutex and semaphore resource access control.
Edit
That’s all about CPU cycles needed for those two OPs. To my knowledge
adduses less CPU cycles thanmov. But then again it is very arch-dependent and questionable. Also, bear in mind that assemblers choice of how to encode a higher-level language instruction is very dependent on the surrounding instructions