hello friends welcome to core basics
coding tutorial in this computer science
concepts tutorial we are going to see
the difference between multi processing
and multi threading both of these are
ways to achieve multitasking now what is
multi tasking when you are doing
multiple tasks at the same time it is
called multitasking for example this mom
she is taking care of baby picking up
the phone call and at the same time
cooking fool so she's doing all these
multiple things at the same time that's
why it's called she called to be doing
multi tasking of a computer in similar
fashion does multiple tasks for example
on my computer I have PowerPoint running
I have browser running I might have
calculated a couple of other programs
running so all these different programs
are basically different processes and if
you want to see those processes you can
see it here in windows task manager if
you go to details tab all these entities
which are listed here they are all
different processes so for example for
Chrome I have all this processes and for
PowerPoint I have this guy here and
there is a PID PID means process ID so
they have that own different process IDs
so understanding processes is pretty
easy
basically there are different programs
running on your computer then what is
actually multiple threads okay so let me
go back to my presentation so multiple
threads basically lives within the same
process so in this diagram here this
outer block is a process which has its
own virtual memory or an address space
now it can create multiple threads
inside it now the difference between
process and third is that threads will
share this outer space now they will
have their own instruction sets they
will be doing each of these threads will
be doing
specific tasks and they will be
exhibiting their own core they have
their own stack memory own instruction
pointer but the only thing that they
share is that a space which means if you
have any global variables to define in
your program they can be accessed by
these threads and heap memory can be
accessed by this Thresh okay whereas if
you look at the processes this is
process one and process two they have
their own address paste okay and if they
ever want to communicate with each other
they can use inter process communication
techniques such as a file on the disk or
a shared memory or a message pipe okay
so from these two pictures you can at
least guess what is the key difference
between process and a thread so the key
difference is players are lightweight
vs. processes are hey wait okay that's
the key difference now if there is a
lightweight why do you even care to
create a new process well first of all
these processes are different programs
written by different companies so they
have to run separately as separate
process and another thing is if you have
any error or a memory leak in one
program or or one process it will not
impact another process versus if you
have that problem in a one thread then
since it is running under is in the
diagram if this thread has a memory leak
then it can potentially impact the
entire process and it can have harmful
effects on these threads and the parent
process all right so that was all about
multi processing and multi-threading
thank you for watching