WEBVTT

00:04.950 --> 00:09.780
So guys, now let us understand the concept of overlapping and non overlapping work.

00:10.020 --> 00:18.120
If the thread T1 is doing work, W1 and thread T2 is doing work W2, then the work W1 and W2 is said

00:18.120 --> 00:23.430
to be overlapping if W1 and W2 operates on the same data.

00:23.430 --> 00:24.240
Right.

00:24.480 --> 00:30.990
So let us understand this with the help of an example, let us suppose that W1 represents sorting the

00:30.990 --> 00:38.220
array A in ascending order and W2 represents sorting the same array A in descending order, right?

00:38.220 --> 00:44.820
So you can see that W1 and W2 are the pieces of work which operate on the same data structure, which

00:44.820 --> 00:45.520
is an array.

00:45.520 --> 00:52.260
A So it simply means that the work W1 and W2 highly overlaps with each other.

00:52.260 --> 00:54.810
In fact they overlap 100%.

00:56.300 --> 01:02.630
So since array is a common data structure on which thread, T1 and T2 are operating right.

01:02.780 --> 01:06.620
Therefore, W1 and W2 are overlapping work.

01:07.160 --> 01:12.920
So a general rule is that that if threads access the same data structure of a process, right?

01:12.920 --> 01:18.440
So for example, suppose you have a process and inside this process you have multiple threads.

01:18.440 --> 01:24.650
And if those threads access the same data structure within a process and those data structure could

01:24.650 --> 01:32.510
be some global variable or some data structure in the heap memory, then work done by two threads are

01:32.510 --> 01:34.430
overlapping work, right?

01:35.310 --> 01:40.950
So it is the nature of work, whether the work is overlapping or non overlapping between the threads

01:40.950 --> 01:45.240
which decides whether the thread needs synchronization or not.

01:45.330 --> 01:50.640
Now we will going to discuss in detail the concepts of thread synchronization in other section of this

01:50.640 --> 01:51.480
course.

01:52.970 --> 02:00.950
But here I want to emphasize that the two threads of the same process may or may not need synchronization

02:00.950 --> 02:05.900
depending whether the work assigned to these threads overlaps or not.

02:05.930 --> 02:11.690
We had discussed one process model in which the process represented a TCP server.

02:12.750 --> 02:20.550
That is coming back to this slide and this Dhcp server used to create one separate thread which interact

02:20.550 --> 02:23.450
with the client on behalf of Dhcp server.

02:23.460 --> 02:30.120
So here the work of each of the worker thread is completely isolated and non-overlapping with each other.

02:30.150 --> 02:36.750
Therefore, there is absolutely no need to implement any thread synchronization technique between the

02:36.750 --> 02:38.940
threads t1, T2 and T3.

02:38.970 --> 02:39.660
Right.

02:39.930 --> 02:43.230
So do not just blindly go for thread synchronization.

02:43.230 --> 02:47.790
First, evaluate whether the threads really need thread synchronization or not.

02:47.820 --> 02:55.170
When I say thread synchronization, I mean I literally means all those heavy terms which you must have

02:55.170 --> 03:01.770
heard somewhere like mutexes condition variables, critical section, and so on.
