Race Condition
A race condition occurs when two or more threads/processes/systems can access shared data and they try to change it at the same time. Because the thread scheduling algorithm can swap between threads at any time, you don't know the order in which the threads will attempt to access the shared data.
Eg : Imagine that you have two threads.
Thread A
if (mark.total != 0)
{
percentage = mark.total/no_of_subjects;
}
Thread B
mark.total = 0;
If thread A is preempted just after if check, B will do mark.total = 0, and when thread A will gain the processor, it will do a "divide by zero".
Concurrency (Interrupt-ability)
Concurrency is when two or more tasks can start, run, and complete in overlapping time periods. It doesn't necessarily mean they'll ever both be running at the same instant. Eg. multitasking on a single-core machine.
Two threads are making progress. This happens in Single processor systems.
Two threads are making progress. This happens in Single processor systems.
Parallelism (Independent-ability)
Parallelism is when tasks literally run at the same time, eg. on a multicore processor.
Two threads are executing simultaneously. In Parallel Computing/Multi Core processor environment
Read more here.
Parallelism is when tasks literally run at the same time, eg. on a multicore processor.
Two threads are executing simultaneously. In Parallel Computing/Multi Core processor environmentRead more here.
Comments
Post a Comment