New answers tagged

1

Practically speaking, the C++ threading (memory) model is directly inspired by the Java Memory Model, and C followed. Hans Böhm was closely involved with the process and has a great resource list. (*) You'll quickly note that your dates are pretty optimistic - this memory model did not exist in 1985 when the first C++ implementations were created. There's ...


2

There are many approaches for concurrency, with different tradeoffs. We have threads with shared mutable state (e.g., SRC-style threading). We have coroutines (like Go). We have actor models with independent processes communicating via message passing (like Erlang or E). I would put CSP on a different level. It's not the same sort of thing. The form of ...


0

It is a possible deadlock. There will be an actual deadlock if each process manages to execute one “wait” before the other one manages to execute the second “wait”. That will happen if both processes try to run their code at almost exactly the same time. Since this is very time dependent, that kind of code will deadlock very rarely - which makes that kind ...


0

Assuming the semaphore only has 1 slot, Yes it can lead to Deadlock Improper use of semaphores with wait queues can cause deadlock, As a good programming practice, a semaphore should be initialized once at the very beginning of your program and before the threads which use it are created. It is a bad practice to reinitialize semaphores in the middle of ...


Top 50 recent answers are included