Imagine using Parallelism in a multi-core system.
Is it possible that the same instructions can be executed simultaneously?
Take the following code:
int i = 0;
if( blockingCondition )
{
lock( objLock )
{
i++;
}
}
In my head it seems that in a system with multiple cores and Parallelism it is very possible that the lock can be checked exactly at the same moment, which leads to an attempt to lock at the same moment, etc ... Is this true?
If so, how can you ensure synchronization between processors?
Also, does this TLS.net TPL handle this type of synchronization? What about other languages?
EDIT
Note that this is not about threads, but Tasks and Parallel Processing.
2
, . , , ?