So, guys, welcome back.
Now, in this section of the course, we will going to attack on Inter-thread communication.
That is how to set up the communication between the threads of the same process.
So we often feel the need to set up communication between independent threads of the process.
And when I say communication, it simply means exchange of data between the threads.
So a big software system may have built as a multi threaded software, right?
And the threads of this multi threaded software may require exchange data with one another.
So it is quite possible that you build a very big, huge software which is divided into independent
modules, say M1, M2 and M3.
And these modules, M1, M2, M3 are running as separate threads of the same process.
And let us say that these modules, M1, M2 and M3 are nothing, but these are three independent threads
of the same process.
P Right.
Now, it may be required that module M1 may want to send some data to module M2 and M2 may want to send
some data to module M3 and so on.
Right.
This is very normal logistics of a typical big software program, right?
So famous IPC techniques are usually used to set up data exchange between the processes.
So note that there are various IPC techniques which exist today in order to facilitate communication
between the processes and technically, nothing is stopping you from using these IPC techniques to facilitate
communication between the threads.
Right.
So you must have come across the names like sockets, message queues, pipes, shared memory.
These are all the tools that your typical operating system provides to set up the communication between
processes running on the system.
Right.
But when it comes to set up communication between threads, technically nothing is stopping you from
using these techniques to facilitate communication between threads.
You can use any of these techniques for data exchange between the threads of the same process, but
still for inter thread communication.
IPC technique is not the recommended way for data exchange.
In fact, the communication between threads is preferred through callback or function pointers.
And the reason is very clear for this.
The reason is that that the communication through callbacks or function pointers is very fast.
In this type of communication.
There is actually no transfer of data, but there is a transfer of computation.
So we will going to understand this point elaborately in the next lecture video.
In communication through function pointers or callbacks.
There is absolutely no need for the special attention required from the kernel or operating system.
This type of communication is completely and independently supported in the user space.
This does not require any underlying operating system support and therefore no kernel resources need
to be explicitly created to carry out communication between the two threads of the same process using
callbacks or function pointers.
Because at the end of the day, callbacks and function pointer is nothing but it is the invocation of
the function.
Right.
And one function invoke another function completely in the user space without the assistance of underlying
operating system or kernel.
Right.
Unless, of course, your function to is a system call.
So now in the next lecture video, let us focus on this point that communication using callbacks or
function pointers do not involve any actual transfer of data, but in fact it involves the transfer
of computation itself.