How web browsers use process & Threads| Chrome Vs Firefox

The essential part of browsers has not changed much. They are all based on processes and threads. In order to understand the environment that the browser is running, we need to understand a few computer parts and what they do.

When you start an application on your computer or phone, the CPU and GPU are the ones powering the application. The Central Processing Unit — or CPU. The CPU can be considered your computer’s brain. A CPU core, pictured here as an office worker, can handle many different tasks one by one as they come in. Graphics Processing Unit — or GPU is another part of the computer. Unlike CPU, GPU is good at handling simple tasks but across multiple cores at the same time. Usually, applications run on the CPU and GPU using mechanisms provided by the Operating System.

Executing program on process and treads

A process can be described as an application’s executing program. A thread is the one that lives inside of process and executes any part of its process’s program. When you start an application, a process is created. The program might create thread(s) to help it do work, but that’s optional.

Treads

A thread of control is an independent sequence of execution of program code in a process. A thread or lightweight process is a basic unit of CPU utilization. A traditional process or heavyweight process is equal to a task with one thread. A traditional process has a single thread that has sole possession of the process’s memory and other resources. Threads share all the process’s memory and other resources. On a multiprocessor, different threads may execute on different processors. On a uni-processor, threads may interleave their execution arbitrarily.

Benefits

® Responsiveness — may allow continued execution if part of the process is blocked, especially important for user interfaces

® Resource Sharing — threads share resources of process, easier than shared memory or message passing

® Economy — cheaper than process creation, thread switching lower overhead than context switching

® Scalability — the process can take advantage of multiprocessor architectures

Single and Multithreaded Processes

Process concept

Process — a program in execution. The program is a passive entity stored on disk (executable file), the process is active. The program becomes a process when executable files loaded into memory. Execution of the program started via GUI mouse clicks, command line entry of its name, etc. One program can be several processes when multiple users executing the same program. Process execution is sequential. A process needs resources (CPU time, memory, files, and I/O devices) to complete the execution successfully.

Process state

◼As a process executes, it changes state

o new: The process is being created

o running: Instructions are being executed

o waiting: The process is waiting for some event to occur

o ready: The process is waiting to be assigned to a processor

o terminated: The process has finished execution

Google Chrome

Chrome has a multi-process architecture and each process is heavily multi-threaded. The main goal is to keep the main thread and IO thread (each process’ thread for handling IPC) responsive. That means offloading any blocking I/O or other expensive operations to other threads. This uses message passing as the way of communicating between threads.

At the top is the browser process coordinating with other processes that take care of different parts of the application. For the renderer process, multiple processes are created and assigned to each tab. Until very recently, Chrome gave each tab a process when it could; now it tries to give each site its own process, including iframes. But if a tab becomes unresponsive but the other tabs related to that is processing.

Which process controls what?

The following table describes each Chrome process and what it controls:

There are even more processes like the Extension process and utility processes. If you want to see how many processes are running in your Chrome, click the options menu icon … at the top right corner, select More Tools, then select Task Manager. This opens up a window with a list of processes that are currently running and how much CPU/Memory they are using.

Mozilla Firefox

Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. Years ago, Firefox was a single-process browser. Now it has improved its architecture to multi-threading. Firefox’s architecture has one main process, GPU process, extension process, and, four tab processes.

Not like Chrome, A new tab doesn’t create their own browser engine. This way uses less memory space. But if a tab becomes unresponsive the other tabs related to that process become unresponsive.

Firefox had support for add-ons and extensions but have not much like chrome. It has excellent tracking control. This browser is very fastest and easy to use. The memory consumption is lower than Chrome. In privacy, Chrome in the top than Firefox.

BSc.(Hons) Software Engineering Undergraduate | University Of Kelaniya. ( https://science.kln.ac.lk/tunits/setu/)