What happens if two process in different processors try to acquire the lock at EXACTLY same time
Ok, so I am reading about synchronization, and I read through various algorithms such as spinlocks, semaphores, and mutex to avoid race condition. However, these algorithms can't prevent race condition in SMP when multiple proceses access the data exactly at the same time. For example, suppose thread 1 in processor A runs lock(mutex1); withdraw(1000); unlock(mutex1); and thread 2 in processor B runs lock(mutex1); deposit(1000); deposit(1000); unlock(mutex1); When both threads run EXACTLY AT THE SAME TIME, both threads will be in critical section simultaneously. The only solution (should be in