How web browsers use Processes and Threads

Maleesha Mihiranga
3 min readAug 3, 2020

What are process & Thread?

Process and Thread are essentially associated. The process is an execution of a program whereas thread is an execution of a program driven by the environment of a process. Another major point that differentiates process and thread is that processes are isolated with each other whereas threads share memory or resources with each other.

Thread is an execution unit that is part of a process. A process can have multiple threads, all executing at the same time. It is a unit of execution in concurrent programming. A thread is lightweight and can be managed independently by a scheduler. It helps you to improve the application performance using parallelism.

Web Browser

a web browser is 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.

Web browsers can show text, audio, video, animation, and more. It is the responsibility of a web browser to interpret text and commands contained in the web page.

Earlier the web browsers were text-based while nowadays graphical-based or voice-based web browsers are also available. Following are the most common web browser available today:

Architecture

There is a lot of web browser available in the market. All of them interpret and display information on the screen however their capabilities and structure vary depending upon implementation. But the most basic component that all web browser must exhibit are listed below:

  • Controller/Dispatcher
  • Interpreter
  • Client Programs

The controller works as a control unit in the CPU. It takes input from the keyboard or mouse, interprets it, and make other services to work on the basis of input it receives.

The interpreter receives the information from the controller and execute the instruction line by line. Some interpreters are mandatory while some are optional For example, an HTML interpreter program is mandatory and java interpreter is optional.

Client Program describes the specific protocol that will be used to access a particular service. Following are the client programs that are commonly used:

  • HTTP
  • SMTP
  • FTP
  • NNTP
  • POP

How to google chrome & firefox use Processes and Threads

Chrome has a multi-process architecture and each process is heavily multi-threaded. In this document, we will go over the basic threading system shared by each process. The main goal is to keep the main thread (a.k.a. “UI” thread in the browser process) and IO thread (each process’ thread for handling IPC) responsive. This means offloading any blocking I/O or other expensive operations to other threads. Our approach is to use message passing as the way of communicating between threads. We discourage locking and thread-safe objects. Instead, objects live on only one thread and we pass messages between those threads for communication.

Every Chrome process has

· a main thread

· an IO thread

· a few more special-purpose threads

Years ago, Mozilla made a fateful decision about the future of Firefox development, one that made it much more difficult to integrate multiprocessing into the existing browser. Roughly 10 years ago, the major way Firefox had distinguished itself compared with Internet Explorer was through its support for add-ons and extensions. But the same add-on abilities that had made the browser popular also made it difficult to add multiprocessor support. Mozilla, therefore, committed to transitioning away from its old add-on model and towards multi-browser web extension support, while simultaneously launching the Electrolysis project to create a new browser version that could support a multi-processing architecture. Currently, the latest versions of Firefox run the browser UI and the web content in separate processes. In the current iteration of this architecture, all browser tabs run within the same process and the browser UI runs in its own individual process.

--

--