Primitive synchronization primitives — safe?

后端 未结 5 1977
孤城傲影
孤城傲影 2020-12-21 04:05

On constrained devices, I often find myself \"faking\" locks between 2 threads with 2 bools. Each is only read by one thread, and only written by the other. Here\'s what I m

5条回答
  •  情书的邮戳
    2020-12-21 05:00

    Concerning the sleep call, you could always just do sleep(0) or the equivalent call that pauses your thread letting the next in line a turn.

    Concerning the rest, this is thread safe if you know the implementation details of your device.

提交回复
热议问题