What part of memory does a mutex lock? (pthreads)

前端 未结 7 1908
独厮守ぢ
独厮守ぢ 2021-01-02 15:34

All the documentation I\'ve read on the pthreads mutex states only that a mutex prevents multiple threads from accessing shared memory, but how do you specify in the program

相关标签:
7条回答
  • 2021-01-02 16:16

    Mutex locks a piece of code. For example:

    mutex.lock();
        //some code here
    mutex.unlock();
    

    If one thread enters the code above it locks it, until it is done with it. At the same time no other thread can execute this piece of code.

    mutex and threads independence

    0 讨论(0)
提交回复
热议问题