0% found this document useful (0 votes)
7 views23 pages

Threads

The document explains the concept of threads as the smallest unit of a process that can be scheduled by the CPU, highlighting their advantages like reduced context switching time and improved application performance through parallelism. It details two types of threads: User Level Threads, managed by applications, and Kernel Level Threads, managed by the operating system, along with their respective advantages and disadvantages. Additionally, it outlines multithreading models and the system boot process, which includes steps from powering on the computer to loading the operating system.

Uploaded by

musicblissful78
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)
7 views23 pages

Threads

The document explains the concept of threads as the smallest unit of a process that can be scheduled by the CPU, highlighting their advantages like reduced context switching time and improved application performance through parallelism. It details two types of threads: User Level Threads, managed by applications, and Kernel Level Threads, managed by the operating system, along with their respective advantages and disadvantages. Additionally, it outlines multithreading models and the system boot process, which includes steps from powering on the computer to loading the operating system.

Uploaded by

musicblissful78
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

[Link].

in

THREADS
• A thread is the smallest unit of a process that can be scheduled and executed by the
CPU. Thread is a small task inside a bigger task (process).

• Threads are also called lightweight processes as they possess some of the properties
of processes.
Click to Edit

• Threads provide a way to improve application performance through parallelism.


Threads represent a software approach to improving performance of operating system
by reducing the overhead thread is equivalent to a classical process.
• Each thread belongs to exactly one process and no thread can exist outside a
process.
• Each thread represents a separate flow of control.
• Threads have been successfully used in implementing network servers and web
Click to Edit server.
• They also provide a suitable foundation for parallel execution of applications on
shared memory multiprocessors.
• Following figure shows the working of the single and multithreaded processes
Click to Edit
Advantages of Thread :

• Thread minimizes context switching time.


• Use of threads provides concurrency within a process.
• Efficient communication.
Click to Edit

• Economy- It is more economical to create and context


switch threads.
• Utilization of multiprocessor architectures to a greater
scale and efficiency.
Types of Thread:
 Threads are implemented in following two ways

 User Level Threads - User managed threads

 Kernel Level Threads - Operating System

managed threads acting on kernel, an operating


system core.
❖User Level Threads :
• In this case, application manages thread management

kernel is not aware of the existence of threads.

• The thread library contains code for creating and

destroying threads, for passing message and data


between threads, for scheduling thread execution and
for saving and restoring thread contexts.

• The application begins with a single thread and begins

running in that thread.


Advantages :
 Thread switching does not require Kernel mode

privileges.
 User level thread can run on any operating system.

 Scheduling can be application specific in the user

level thread.
 User level threads are fast to create and manage.
Disadvantages
 In a typical operating system, most system calls are

blocking.

 Multithreaded application cannot take advantage of

multiprocessing
❖ Kernel Level Threads
o In this case, thread management done by the Kernel.

o There is no thread management code in the application

area.

o Kernel threads are supported directly by the operating

system.

o Any application can be programmed to be multithreaded.

o All of the threads within an application are supported

within a single process.


 The Kernel maintains context information for the
process as a whole and for individuals’ threads
within the process.
 Scheduling by the Kernel is done on a thread basis.

 The Kernel performs thread creation, scheduling


and management in Kernel space.
 Kernel threads are generally slower to create and
manage than the user threads.
✓Advantages
 Kernel can simultaneously schedule multiple

threads from the same process on multiple


processes.
 If one thread in a process is blocked, the Kernel can

schedule another thread of the same process.


 Kernel routines themselves can multithreaded.
✓ Disadvantages

 Kernel threads are generally slower to create and manage than the

user threads.

 Transfer of control from one thread to another within same process

requires a mode switch to the Kernel.

➢ Multithreading Models
 Some operating system provides a combined user level

thread and Kernel level thread facility.

 Solaris is a good example of this combined approach.


 In a combined system, multiple threads within the
same application can run in parallel on multiple
processors and a blocking system call need not
block the entire process.
 Multithreading models are three types

 Many to many model

 Many to one model

 One to one model


Many to Many Model
 In this model, many user level threads multiplexes to the

Kernel thread of smaller or equal numbers.

 The number of Kernel threads may be specific to either a

particular application or a particular machine.

 Following diagram shows the many to many model.

 In this model, developers can create as many user threads

as necessary and the corresponding Kernel threads can run


in parallels on a multiprocessor.
Many to one model
• Many to one model maps many user level threads to one

Kernel level thread.

• Thread management is done in user space.

• When thread makes a blocking system call, the entire

process will be blocks.

• Only one thread can access the Kernel at a time, so

multiple threads are unable to run in parallel on


multiprocessors.
• If the user level thread libraries are implemented in the operating

system in such a way that system does not support them then Kernel
threads use the many to one relationship modes.
One to one model
• There is one to one relationship of user level thread to the

kernel level thread.


 This model provides more concurrency than the many to
one model.
 It also another thread to run when a thread makes a
blocking system call.
 It supports multiple thread to execute in parallel on
microprocessors.
 Disadvantage of this model is that creating user thread

requires the corresponding Kernel thread.

 OS/2, Windows NT and windows 2000 use one to one

relationship model.
SYSTEM BOOT
 System boot is the process of starting a computer when you turn it on.
1. Power On
• You press the power button on your computer.
2. POST (Power-On Self-Test)
• The computer checks hardware (RAM, CPU, keyboard, etc.).
• If there is an error (like no RAM), you may hear beeps or see an error message.
3. Load Bootloader
• The BIOS/UEFI finds the bootloader (like GRUB or Windows Boot Manager)
from storage (HDD/SSD).
4. Load Operating System (OS)
• The bootloader loads the OS kernel (Windows, Linux, macOS).
• The kernel initializes drivers and system services.
5. User Login & Ready to Use
• The OS loads the desktop, icons, and programs.
• You can now use your computer!

You might also like