How web browsers use process and threads
Process and Threads
Process means the execution of the program in any application. Thread is the segment of the process which means the basic unit to which the operating system allocates processor time. A process can contain multiple threads.
Single-threaded and multi-threaded process
Single-threaded processes contain the execution of instructions in a single sequence. The opposite of single-threaded processes is multithreaded processes that allow the execution of multiple parts of a program at the same time.
Process vs Thread
The primary difference is that threads within the same process run in shared memory space, while processes run in separate memory spaces.
Threads are not independent of one another like processes are, and as a result, threads share with other threads their code section, data section, and OS resources.
The architecture of a web browser
Web Browser is an application software that allows us to view and explore information on the web. Users can request any web page by just entering a URL into address bar.
The basic web architecture is two-tiered and characterized by a web client that displays information content and a web server that transfers information to the client. This architecture depends on three key standards: HTML for encoding document content, URIs for naming remote information objects in a global namespace, and HTTP for staging the transfer.
HyperText Markup Language(HTML) — the common representation language for hypertext documents on the Web.
Universal Resource Identifier(URI)- There are two types of URIs, Universal Resource Names (URN) and the Universal Resource Locators (URL).
HyperText Transfer Protocol(HTTP)- an application-level network protocol for the WWW.
Simple Architecture of a web browser
User Interface allows end-users to interact with all the visual elements available in the web browser. The browser engine functions as an intermediary or a bridge between the user interface and the rendering engine. Rendering engine is responsible for rendering a specific web page requested by the user on their screen.
Threading in Chrome
Chrome is a multi-threaded web browser which has a multi-process architecture. Every chrome process has a main thread and an IO thread. In Chrome, each and every tab you open gets its own content process.
Main thread- UI thread in the browser process.
IO thread- each process’ thread for handling IPC
Threading in Firefox
The new Firefox 54 is capable of using multiple threads simultaneously a major step forward for the browser. In 2016, the company launched the first phase of Electrolysis, by splitting its UI and its web page content to run in two different processes. With the release of Firefox 54, Mozilla has completed its transition to a multithreaded arch.
Mozilla claims that Firefox also uses dramatically less memory than other competing browsers, with Chrome using 1.77x more RAM than Firefox in 64-bit and 2.44x in 32-bit mode. The differences were less dramatic in Mac OS X and Linux.
Firefox is likely to slow down the computer faster than Chrome is. But Mozilla claims that Firefox loads websites slightly faster than Chrome. Firefox does seem snappier sometimes, but not always. If the user wants to enhance his browsing experience both Google Chrome and Firefox have stores for add-ons and extensions. Check here, Chrome’s or Firefox’s store.