Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - atomic_read() equivalent mechanism in QNX: Page 1 of 15 (15 Items)
   
atomic_read() equivalent mechanism in QNX  
Hello friends,

I am using atomic operations provided by the QNX to change and access (or check) variable value between two threads... 
Here is pseudo implementation of my case.

volatile unsigned digit;

thread_1()
{
       while(1) {
           if(digit > 10)
               break;
           else
              ....
       }
   ...
}

thread_2()
{
       while(1) {
           delay(10);

           atomic_add(&digit, 1);
       }
   ...
}


Now, As far as I know there isn't any function (like atomic_read() in Linux) to read and then test variable atomically 
which I can use for checking "digit" value in "If statement" in thread_1.

So, please anyone tell me, is it enough what I have done in above case or do I have to use other synchronization 
mechanism like mutex or spinlock?


Thank you very much
Apurva