0

Hi All,

I have a doubt regarding "threadsafe". Consider the following scenario....

Thread #1:
          fun1() {
                  lock();
                  writestring(ptr, pconfig);
                  unlock();
                  }

     Thread #1:
          fun2() {
                   lock();
                   writestring(ptr, pconfig);
                   unlock();
                   }

          bool writestring(char *ptr, char *pconfig) {
              //this code should not be shared across threads. One thread should access at                                          
              //given point of time 
              memcpy();
              ............
              }

My doubt here is :

Will writestring is accessed by only one thread at any given point of time i.e. Is it Thread Safe? If no, then how can I make it threadsafe?

My application is multithreaded and crashing at memcpy i.e. memory corruption. Is thread safe is the reason for memory corruption? Please reply me.

Thanks in advance.

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.