“How web browsers use process & Threads” comparing chrome & Firefox
First of all I will explain what is a web browser. Belongs to the Wikipedia “A web browser (commonly referred to as a browser) is a software application for accessing information on the World Wide Web. When a user requests a web page from a particular website, the web browser retrieves the necessary content from a web server and then displays the page on the user’s device”. As a software application they use process and threads for doing the tasks belongs to user requests.
Then we should know about what is a process? “Process means any program is in execution. Process control block controls the operation of any process. Process control block contains the information about processes for example: Process priority, process id, process state, CPU, register etc. A process can creates other processes which are known as Child Processes. Process takes more time to terminate and it is isolated means it does not share memory with any other process.” There is a word multiprocessing. That is not special thing it says OS support to execute more thane one process at a time.
Then what is a thread? “Thread is the segment of a process means a process can have multiple threads and these multiple threads are contained within a process. A thread have 3 states: running, ready, and blocked.Thread takes less time to terminate as compared to process and like process threads do not isolate.” Multithreading is ability that OS support to execute multiple paths in one process.
Now we can come to our main topic “how web browser use process and thread”. To explain I will get two different web browsers chrome and Firefox using this two methods. Shall we take one by one chrome and firefox for better understanding.
Chrome has a multiprocessing architecture and each process is heavily multi-threaded. There main goal is to keep the main thread and IO thread responsive. That implies that offloading any blocking I/O or other expensive operations to other threads.
In this case when user open a new tab chrome create a new process for that tab with multi-threads. So there is a large benefit of this system if in chrome one tab(process) is crashes it will not crash entire browser. simply net effected to other processes(tabs).
Because of this the performance of chrome is high but it requests more power and space to execute.However chrome have many options to protect our privacy and security.
Firefox was a single process browser in the beginning. But nowadays improved its architecture to support multi threading.Firefox now creates up to 4 separate processes for web page content. So, If you create 4 tabs first, each use those 4 processes, and the additional tabs run using threads within the previous created 4 tabs. Multiple tabs within a process share the browser engine that already exists in memory, instead of each creating their own.
Because of this firefox request low power and space than google chrome.After releasing Firefox Quantum also features a ideal multi-process architecture that well balances speed with memory consumption. That means Firefox Quantum often loads pages faster than Chrome.
We can have a better understanding from these images,
Finally we can say chrome uses multiprocessing and firefox uses multi threading. so each tab in chrome is a process whereas in firefox each tab is a thread. since multithreading is faster, firefox is faster(due to shared memory, context switching is faster in threads).however, it is important to note that, chrome is less likely to crash since if one tab(process) crashes, it won’t crash the entire browser. opposite is true in case of firefox.