I have global variable which is being shared between threads (problem
is not connected with thread). Without using any mutex i have do some
operation global variable in *consistent* way.
consider following code :
int i = 0
fun (int j)
{
i = i + j ; i = i * somefun(i,j) ; /*i meant here is, we are doing
lot of operations */
}
above func is being executed by threads, We can change the
implementation of func .however , we need to maintain what that fun
does on that variable.
How can we implement the concept of optimistic locking here. I got lot
defination of optimistic locking on internet .
But i couldnt find any implementation. So i thought of implementing one
small programme . Can we apply concept of optimistic locking here ?
my guess,here we need to write pure C code.