[go: up one dir, main page]

0% found this document useful (0 votes)
12 views4 pages

Process Thread

The document explains the concepts of processes and threads in computer engineering, highlighting that a process is an instance of a program in execution, while a thread is a lightweight subprocess within a process. It details how processes and threads work, their features, and the differences between them, emphasizing that processes are independent and heavier, whereas threads share resources and require synchronization. Additionally, it outlines the types of threads: user-level threads managed by users and kernel-level threads managed by the operating system.

Uploaded by

zoro80290
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Process Thread

The document explains the concepts of processes and threads in computer engineering, highlighting that a process is an instance of a program in execution, while a thread is a lightweight subprocess within a process. It details how processes and threads work, their features, and the differences between them, emphasizing that processes are independent and heavier, whereas threads share resources and require synchronization. Additionally, it outlines the types of threads: user-level threads managed by users and kernel-level threads managed by the operating system.

Uploaded by

zoro80290
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Subject: DC Semester:VIII

What is Process?
A process is an instance of a program that is being executed. When we run a program,
it does not execute directly. It takes some time to follow all the steps required to execute
the program, and following these execution steps is known as a process.

A process can create other processes to perform multiple tasks at a time; the created
processes are known as clone or child process, and the main process is known as
the parent process. Each process contains its own memory space and does not share it
with the other processes. It is known as the active entity. A typical process remains in the
below form in memory.

How do Processes work?


When we start executing the program, the processor begins to process it. It takes the
following steps:

o Firstly, the program is loaded into the computer's memory in binary code after translation.
o A program requires memory and other OS resources to run it. The resources such that
registers, program counter, and a stack, and these resources are provided by the OS.
o A register can have an instruction, a storage address, or other data that is required by the
process.
o The program counter maintains the track of the program sequence.
o The stack has information on the active subroutines of a computer program.
o A program may have different instances of it, and each instance of the running program
is knowns as the individual process.

Features of Process
o Each time we create a process, we need to make a separate system call for each process
to the OS. The fork() function creates the process.
o Each process exists within its own address or memory space.
o Each process is independent and treated as an isolated process by the OS.

Prof.S.S. Aloni Dept.of Computer Engineering


Subject: DC Semester:VIII

o Processes need IPC (Inter-process Communication) in order to communicate with each


other.
o A proper synchronization between processes is not required.

What is Thread?
A thread is the subset of a process and is also known as the lightweight process. A process
can have more than one thread, and these threads are managed independently by the
scheduler. All the threads within one process are interrelated to each other. Threads have
some common information, such as data segment, code segment, files, etc., that is
shared to their peer threads. But contains its own registers, stack, and counter.

How does thread work?


As we have discussed that a thread is a subprocess or an execution unit within a process.
A process can contain a single thread to multiple threads. A thread works as follows:

o When a process starts, OS assigns the memory and resources to it. Each thread within a
process shares the memory and resources of that process only.

Prof.S.S. Aloni Dept.of Computer Engineering


Subject: DC Semester:VIII

o Threads are mainly used to improve the processing of an application. In reality, only a
single thread is executed at a time, but due to fast context switching between threads
gives an illusion that threads are running parallelly.
o If a single thread executes in a process, it is known as a single-threaded And if multiple
threads execute simultaneously, then it is known as multithreading.

Types of Threads
There are two types of threads, which are:

1. User Level Thread

As the name suggests, the user-level threads are only managed by users, and the kernel
does not have its information.

These are faster, easy to create and manage.

The kernel takes all these threads as a single process and handles them as one process
only.

The user-level threads are implemented by user-level libraries, not by the system calls.

2. Kernel-Level Thread

The kernel-level threads are handled by the Operating system and managed by its kernel.
These threads are slower than user-level threads because context information is managed
by the kernel. To create and implement a kernel-level thread, we need to make a system
call.

Features of Thread
o Threads share data, memory, resources, files, etc., with their peer threads within a process.
o One system call is capable of creating more than one thread.
o Each thread has its own stack and register.
o Threads can directly communicate with each other as they share the same address space.
o Threads need to be synchronized in order to avoid unexpected scenarios.

Prof.S.S. Aloni Dept.of Computer Engineering


Subject: DC Semester:VIII

Key Differences Between Process and Thread


o A process is independent and does not contain within another process, whereas all threads
are logically contained within a process.
o Processes are heavily weighted, whereas threads are light-weighted.
o A process can exist individually as it contains its own memory and other resources, whereas
a thread cannot have its individual existence.
o A proper synchronization between processes is not required. In contrast, threads need to
be synchronized in order to avoid unexpected scenarios.
o Processes can communicate with each other using inter-process communication only; in
contrast, threads can directly communicate with each other as they share the same address
space.

Prof.S.S. Aloni Dept.of Computer Engineering

You might also like