Was asked this question for an interview and really wasn't sure how to answer it. Can anyone suggest examples of where a bug will only present itself when using multiple CPU/core and NEVER happen on a single CPU?

The question didn't mention "threading", i.e. nothing specific about threads running within one process (sharing the same memory space), where I know synchronization ought to take place if accessing shared data (using critical section, mutex etc).

However, this question suggests that the "problem" is with running in parallel on two/more CPUs. Examples would be much appreciated.

Have spent the whole day on google - maybe just need a bit of a pointer :?:

Thank you

6 Years
Discussion Span
Last Post by template<>

A multi-thread program that's shares common data amongst the threads can run bug free on a single core CPU but fail on a multi-core CPU..How do you correct this situation? You anticipate and correct the possibility of two or more threads writing/reading common data by using a mutex or semaphore.


But why is the problem directly related to it being multi core?? When running multiple threads in a process on a single CPU with shared resources - one also uses Mutex,Semaphore,critical sections (if it is in the same process only) etc.

The question implies that when running on multiple CPU, other/additional factors need to be taken into consideration and if not - bugs may appear. I am trying to pinpoint what these are:

(*) Is it something to do with inter-processor communication?
(*) Do the different CPUs have different clocks/scheduling?

Thanks for any clarification and suggestions


A single core CPU can only run one thread at a time, a multi-core CPU can run more than one thread at a time and because of this we could have two or more threads modifying the same data at the same time.

Edited by gerard4143: n/a


A problem unique to multi-core is that each core has its own cache and caches between cores must be synchronized if different threads are accessing the same variable.

So you may get into a situation where a shared resource has different values in the different cache, i.e. the caches did not synchronize. For example this may happen if a shared resource is not declared volatile.

Votes + Comments
Interesting point
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.