We're not on the same page here :)
There is
in hardware a command that does the following in an atomic fashion:
T oldValue = readWrite(T* memorylocation, T newValue);
The result of doing it is for example:
1 2
|
int i = 5;
int value = readWrite(&i, 1);
|
then i = 1 and value = 5.
The idea is that no matter what, the memorylocation's value is changed to newValue. However, I wanted to know the old value as well. In essense the hardware function reads the old value, stores the new one, and returns the old (all in
one disk access). Unfortunately I forgot the name...
I simply want to access this functionality in C.
Maybe swapping is an option?