You are on page 1of 12

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION,

MUMBAI

A Project
Report
On
“THREAD”

DIPLOMA
In
ELECTRONIS &COMPUTER ENGINEERING
Submitted by
MR.MARUTI KRUSHNA PATIL
MR. OMKAR SHIVAJI PATIL
MR. PRATIK PARASHRAM YADDUKAR
MR.ABDULREHMAN NAIKWAD

UNDER THE GUIDANCE OF

MR.R.B.MORE

DEPARTMENT OF ELECTRONICS &COMPUTER ENGINEERING

SANT GAJANAN MAHARAJ RURAL POLYTECHNIC,


MAHAGAON ACADEMIC YEAR 2023-2024
SANT GAJANAN MAHARAJ RURAL HOSPITAL &RESEARCH CENTER, MAHAGAON
“SANT GAJANAN MAHARAJ RURAL POLYTECHNIC”
A/P –MAHAGAON, SITE –CHINCHEWADI, TAL-GADHINGLAJ, DIST-KOLHAPUR

Certificate
This is to that the following students of FIFTH semester of Diploma in ELECTRONICS
&COMPUTER ENGINEERING of Institute SANT GAJANAN MAHARAJ RURAL
POLYTECHNIC,MAHAGAON-416503. (CODE-0965) has completed Micro project
“THREAD” satisfactory in subject OSY subject Code 22516 academic year 2023to 2024as
prescribed in the curriculum.

ROLL NO ENROLLMENT NO SEAT NO STUDENT NAME

20 2209650460
MR. PRATIK PARASHRAM YADDULKAR
09 2109650195 MR.MARUTI KURSHNA PATIL

20 2209650463 MR. OMKAR SHIVAJI PATIL

03 2109650180 MR.ABDULREHMAN NAIKWAD

DATE: - -2023 PLACE: MAHAGAON

MR.R.B.MORE Mr.M.P.Patil Mrs.R.S. Patil


(Project Guide) (Head of Department) (Principal)
Index

Sr no. Content Page No.

1 Introduction 1

2 Aims of Micro-Project 1

3 Course Outcomes Achieved 13

4 Actual Methodology Followed 13

5 Skill Developed 13

6 Application of this Microproject 13

7 References and Bibliography 23


1. Introduction

In an operating system, a thread is the smallest unit of execution, also known as a

lightweight process. Threads exist within a process and share its resources, such as mem-

ory and file handles, making them more efficient for multitasking and parallel processing.

Threads allow for concurrent execution of tasks within a single process, and they can

run independently or communicate with each other through shared memory. Threads

are commonly used in modern operating systems to improve system responsiveness and

utilize multi-core processors effectively Categories in Scheduling

2. Aims of Micro-Project

1. To learn about Thread.

2. Learn to types of Threads and it’s work.

3. Course Outcomes Achieved

1. Explain characteristicsc of the given multithreading model.

2. Describe the benefits of thread.


Thread
A thread is the smallest unit of execution in a process. In other words, a thread is a

sequence of instructions within a program that can be executed independently of other

code.

A thread is a basic unit of CPU utilization; it comprises a thread ID, a program

counter, a register set, and a stack. It shares with other threads belonging to the same

process its code section, data section, and other operating-system resources, such as open

files and signals.

A traditional process has a single thread of control. If a process has multiple threads

of control, it can perform more than one task at a time. Figure illustrates the difference

between a traditional single-threaded process and a multithreaded process.

The process can be split down into so many threads. For example, in a browser,

many tabs can be viewed as threads. MS Word uses many threads - formatting text

from one thread, processing input from another thread, etc.

There are two types of threads :


1. Kernel level thread.

2. User-level thread.
Benefits of Thread
 Enhanced throughput of the system

When the process is split into many threads, and each thread is treated as a job, the

number of jobs done in the unit time increases. That is why the throughput of the

system also increases

 Effective Utilization of Multiprocessor system When you have more than

one thread in one process, you can schedule more than one thread in more than

one processor.

 Faster context switch

The context switching period between threads is less than the process context

switch- ing. The process context switch means more overhead for the CPU.

 Responsiveness

When the process is split into several threads, and when a thread completes its exe-

cution, that process can be responded to as soon as possible.

 Communication

Multiple-thread communication is simple because the threads share the same address

space, while in process, we adopt just a few exclusive communication strategies for com-

munication between two processes.

 Resource sharing

Resources can be shared between all threads within a process, such as code, data, and

files. Note: The stack and register cannot be shared between threads. There is a stack

and register for each thread.


Types of Thread

1.User-Level Thread

User threads can be easily implemented and it is implemented by the user. If a user

performs a user-level thread blocking operation, the whole process is blocked. The kernel

level thread does not know nothing about the user level thread. The entire process is

blocked if a user executes a user-level operation of thread blocking. The kernel-level

thread is completely unaware of the user-level thread. User-level threads are managed

as single-threaded processes by the kernel-level thread. User Level Thread is a type of

thread that is not created using system calls. The kernel has no work in the management

of user-level thread.

Advantages of User- Level Thread :

Implementation of the User-Level Thread is easier than Kernel Level Thread.

User-Level Thread is more efficient than Kernel-Level Thread.

It does not require modifications of the operating system.

It is simple to create, switch, and synchronize threads without the intervention of

the process.

Disadvantages of User-level threads :

User-level threads lack coordination between the thread and the kernel.

If a thread causes a page fault, the entire process is blocked


2.Kernel-Level Thread

Kernel-level threads are implements in kernel space.All the thread management ac-

tivities are carried out in kernel space.Kernel threads requires more time to create and

manage than the user threads.Thread management is carried out by kernel.

Kernel threads are supported directly by the operating system The kernel performs

thread creation, scheduling, and management in kernel space.Also, in a multiprocessor

environment, the kernel can schedule threads on different processors.

The implementation of kernel threads is more difficult than the user thread. Context

switch time is longer in the kernel thread. If a kernel thread performs a blocking operation,

the Banky thread execution can continue. Example: Window Solaris.

Advantages of Kernel-level threads:

The kernel-level thread is fully aware of all threads.

The scheduler may decide to spend more CPU time in the process of threads being

large numerical.

The kernel-level thread is good for those applications that block the frequency.

Disadvantages of Kernel-level threads:

The kernel thread manages and schedules all threads.

The implementation of kernel threads is difficult than the user thread.

The kernel-level thread is slower than user-level threads.


Multithreading Model:

Multithreading allows the application to divide its task into individual threads. In

multi-threads, the same process or task can be done by the number of threads, or we

can say that there is more than one thread to perform the task in multithreading. With

the use of multithreading, multitasking can be achieved. There are three types:

1. Many to One model

2. One to one model

3. Many to many model

1. Many to One Model:

Many user level threads mapped to single kernel thread.Used on systems that do not

support kernel threads.Thread management is done in user space,so it is efficient.In this

the entire process will block if a thread makes a blocking system call.Only one thread

access the kernel at a time,multiple threads are unable to run in parallel on multiprocessor.

The disadvantage of this model is that since there is only one kernel-level thread

schedule at any given time, this model cannot take advantage of the hardware acceleration

offered by multithreaded processes or multi-processor systems. In this, all the thread

management is done in the userspace. If blocking comes, this model blocks the whole

system.
2. One to One Model:

The One-to-one model it allows multiple thread to run in parallel on

multiprocessor.It provides more concurrency than the many-to-one model by allowing

another thread to run when a thread makes a blocking system call.It also allows

multiple threads to run in parallel on multiprocessors.

The one-to-one model maps a single user-level thread to a single kernel-level thread.

This type of relationship facilitates the running of multiple threads in parallel. However,

this benefit comes with its drawback. The generation of every new user thread must

include creating a corresponding kernel thread causing an overhead, which can hinder

the performance of the parent process. Windows series and Linux operating systems try

to tackle this problem by limiting the growth of the thread count.


3. Many to Many Model:

The many-to-many model multiplexes many userlevel threads to a smaller or equal

number of kernel threads. The number of kernel threads may be specific to either a

particular application or a particular machine Developers can create as many user threads

as necessary, and the corresponding kernel threads can run in parallel on a multiprocessor.

Also, when a thread performs a blocking system call, the kernel can schedule another

thread for execution.

The developer can create as many threads at both levels but may not be the same.

The many to many model is a compromise between the other two models. In this

model, if any thread makes a blocking system call, the kernel can schedule another

thread for execution. Also, with the introduction of multiple threads, complexity is

not present as in the previous models. Though this model allows the creation of

multiple kernel threads, true concurrency cannot be achieved by this model. This is

because the kernel can schedule only one process at a time.


1.Advantages Of Threads
 Improved overall performance of a program

 Increased responsiveness of the program

 Faster context switching time

 Shared memory and resources within a process

 Faster communication

 Concurrency within a process

 Enhanced throughput of the system

 Reduced complexity of big applications

2.Disadvantages of threads
 Threads depend on the system and the process to run, and are not independent .

 Threads make the code difficult to debug and maintain, and require exception
handling inside the worker method .

 Threads share global variables and many library functions are not thread safe, which
can lead to inadvertent modification of shared state or crashes ,

 Threads consume memory and CPU resources for creation and execution .

 Threads are not reusable and may require more hardware than software

12

You might also like