Professional Documents
Culture Documents
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
MR.R.B.MORE
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.
20 2209650460
MR. PRATIK PARASHRAM YADDULKAR
09 2109650195 MR.MARUTI KURSHNA PATIL
1 Introduction 1
2 Aims of Micro-Project 1
5 Skill Developed 13
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
2. Aims of Micro-Project
code.
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
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
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
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
one thread in one process, you can schedule more than one thread in more than
one processor.
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-
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-
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
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
thread is completely unaware of the user-level thread. User-level threads are managed
thread that is not created using system calls. The kernel has no work in the management
of user-level thread.
the process.
User-level threads lack coordination between the thread and the kernel.
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
Kernel threads are supported directly by the operating system The kernel performs
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 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.
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:
Many user level threads mapped to single kernel thread.Used on systems that do not
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
management is done in the userspace. If blocking comes, this model blocks the whole
system.
2. One to One Model:
another thread to run when a thread makes a blocking system call.It also allows
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
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
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
Faster communication
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