Is there a way to ensure atomicity while having a multithreaded program with signal handlers?

前端 未结 3 1488
离开以前
离开以前 2021-01-23 16:10

If I have a program like this (in pseudocode):

mutex_lock;
func() {
    lock(mutex_lock);
    // Some code (long enough to make a
    // race condition if no pro         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-23 16:22

    You may use the test mutex functions (trylock) in this kind of undefined situations, to be safe. And with this, you don't necessarily need to block too.

提交回复
热议问题