So guys, now let us understand the concept of overlapping and non overlapping work.
If the thread T1 is doing work, W1 and thread T2 is doing work W2, then the work W1 and W2 is said
to be overlapping if W1 and W2 operates on the same data.
Right.
So let us understand this with the help of an example, let us suppose that W1 represents sorting the
array A in ascending order and W2 represents sorting the same array A in descending order, right?
So you can see that W1 and W2 are the pieces of work which operate on the same data structure, which
is an array.
A So it simply means that the work W1 and W2 highly overlaps with each other.
In fact they overlap 100%.
So since array is a common data structure on which thread, T1 and T2 are operating right.
Therefore, W1 and W2 are overlapping work.
So a general rule is that that if threads access the same data structure of a process, right?
So for example, suppose you have a process and inside this process you have multiple threads.
And if those threads access the same data structure within a process and those data structure could
be some global variable or some data structure in the heap memory, then work done by two threads are
overlapping work, right?
So it is the nature of work, whether the work is overlapping or non overlapping between the threads
which decides whether the thread needs synchronization or not.
Now we will going to discuss in detail the concepts of thread synchronization in other section of this
course.
But here I want to emphasize that the two threads of the same process may or may not need synchronization
depending whether the work assigned to these threads overlaps or not.
We had discussed one process model in which the process represented a TCP server.
That is coming back to this slide and this Dhcp server used to create one separate thread which interact
with the client on behalf of Dhcp server.
So here the work of each of the worker thread is completely isolated and non-overlapping with each other.
Therefore, there is absolutely no need to implement any thread synchronization technique between the
threads t1, T2 and T3.
Right.
So do not just blindly go for thread synchronization.
First, evaluate whether the threads really need thread synchronization or not.
When I say thread synchronization, I mean I literally means all those heavy terms which you must have
heard somewhere like mutexes condition variables, critical section, and so on.