In C, this will depend on your platform, i.e. your combination of compiler, processor architecture, and operating system.
Your compiler can choose how to use the internal registers and processor instructions so that the executable seems to fulfill the intent of the program. And C knows nothing about threads. Typically, the operating system should provide a thread library.
There may be processors that can write to an element in your array, reading a much larger patch of memory than just one element, and then overwrite only the correct bits that form one element inside the internal registers, and then write the entire patch back. A single-threaded program will work fine, but two or more threads that interrupt each other can cause chaos in the array.
On the other hand, this may work very well.
And as already mentioned, read-only access is always wonderful.
In addition, Google is your friend. He found this stackoverflow question .
quamrana
source share