June 9th, 2012, 12:15 pm
QuoteHow to make thread synchronization without using mutex, semorphore, spinLock and futex ?Once way is to design your application to be embarassingly parallel i.e. no shared data. You can use domain decomposition, replication, pipes/filters etc. If it is possible; if not, you can't. Then you need shared data patterns, e.g. reader/writer locks or even upgradeable locks.QuoteUse global bool variable as a flag, if thread 5 does not set it true, all other threads wait at one point and also set theirflag variable true. After the thread 5 find all threads' flag variables are true, it will set it flag var true. Very bad idea. beware compiler optimisations, non-atomic operations and cache misses.
Last edited by
Cuchulainn on June 8th, 2012, 10:00 pm, edited 1 time in total.