educative.io

Strong memory model

can a core execute only one atomic operation at a time? Does the example in with two threads run on a single core?


Course: https://www.educative.io/courses/concurrency-with-modern-cpp
Lesson: Educative: Interactive Courses for Software Developers

Hi @Aditya_Sharma,

Great question! In a system with multiple cores, each core is capable of executing its own atomic operations independently. So, in a multi-core system, different cores can handle multiple atomic operations simultaneously.

Now, regarding the example with two threads, it’s important to note that threads can be executed on different cores or on the same core, depending on the system’s configuration and workload. If the system has multiple cores, each thread may run on a separate core simultaneously. However, if the system has only one core, the threads will take turns executing in a process called context switching.

In the context of the Strong Memory Model and sequential consistency, the guarantees apply to the overall order of operations across all threads. Sequential consistency ensures that operations on atomics appear to be executed in a specific order, providing a clear and consistent view of the program’s execution.

Feel free to ask if you have more questions or if there’s anything else you’d like to explore further!

Happy Learning :slight_smile: