Multi-process vs. multi-threading

General discussion and chat (archived)
User avatar
gracious1
Keeps coming back
Keeps coming back
Posts: 891
Joined: 2016-05-15, 05:00
Location: humid upstate NY

Multi-process vs. multi-threading

Unread post by gracious1 » 2017-08-22, 03:15

adisib wrote:Multi-threading is not at all the same thing as multi-process. Multi-threading is useful, important, and used in Pale Moon. Multi-process is not something that should be used in Pale Moon, and Firefox only gets a responsiveness increase from it because they made APZ require it for some strange reason.
Okay, so what is the difference, then between these two things, then? :? :coffee:
20 July 1969 🌗 Apollo 11 🌓 "One small step for [a] man, one giant leap for mankind." 🚀

adisib
Lunatic
Lunatic
Posts: 380
Joined: 2015-06-13, 03:34
Location: KY

Re: Multi-process vs. multi-threading

Unread post by adisib » 2017-08-22, 03:58

gracious1 wrote: Okay, so what is the difference, then between these two things, then? :? :coffee:
https://en.wikipedia.org/wiki/Thread_(computing)#Threads_vs._processes
Threads differ from traditional multitasking operating system processes in that:

processes are typically independent, while threads exist as subsets of a process
processes carry considerably more state information than threads, whereas multiple threads within a process share process state as well as memory and other resources
processes have separate address spaces, whereas threads share their address space
processes interact only through system-provided inter-process communication mechanisms
context switching between threads in the same process is typically faster than context switching between processes.

Systems such as Windows NT and OS/2 are said to have cheap threads and expensive processes; in other operating systems there is not so great a difference except the cost of an address space switch which on some architectures (notably x86) results in a translation lookaside buffer (TLB) flush.

...

a process is a unit of resources, while a thread is a unit of scheduling and execution

...

A process is a "heavyweight" unit of kernel scheduling, as creating, destroying, and switching processes is relatively expensive.

A kernel thread is a "lightweight" unit of kernel scheduling. At least one kernel thread exists within each process. If multiple kernel threads exist within a process, then they share the same memory and file resources.
To try to put it in basic terms, a process is essentially an independent program on your computer, not really designed to interact with other processes as there are security and reliability problems that can result if they can easily do so.
Multithreading is essentially a way of allowing your processor to multi-task and do multiple things at once within a process, such as to separate the user interface from background work so that the background work doesn't hinder your use of the program due to non-reponsiveness, or to use more than one core of your processor to do a job that is well suited to be worked on my multiple cores.

Processes can communicate with each other just as threads can communicate with each other, but Inter-process-communication has a lot of overhead and problems and should generally be avoided when not necessary as processes are designed with independence from each other in mind.

Locked