This document discusses threads and multithreading in operating systems. A thread is a flow of execution through a process with its own program counter, registers, and stack. Multithreading allows multiple threads within a process to run concurrently on multiple processors. There are three relationship models between user threads and kernel threads: many-to-many, many-to-one, and one-to-one. User threads are managed in userspace while kernel threads are managed by the operating system kernel. Both have advantages and disadvantages related to performance, concurrency, and complexity.
2. Threads
A threads is a flow of execution through the
process code, with its own program counter,
System register and stack. A thread is also called
a light weigth process. Threads provide a way to
improve application performance through
parallelism.
Each thread belongs to exactly one process and
no thread can exits outside a process.
4. Concept of Multithreads
• Some operating system provide a combined
user level thread and Kernel level thread
facility.
• Multiple threads within the same application
can run in parallel on multiple processors and
a blocking system call need not block the
entire process.
1.Many to many relationship.
2.Many to one relationship.
3.One to one relationship.
5. Many to Many
The many-to-many model multiplexes any number of user
threads onto an equal or smaller number of kernel threads,
combining the best features of the one-to-one and many-to-
one models.
6. Many to one
• In the many-to-one model, many user-level threads are all
mapped onto a single kernel thread. Thread management is
handled by the thread library in user space, which is efficient
in nature.
7. One to one
Each user thread maps to one kernel thread. provides more
concurrency, if one thread makes a blocking call another
thread is allowed to run. Creating user thread requires
creating coorresponding kernel thread.
10. User Level Threads (ULT)
• User level thread implement
in user level libraries, So
Thread switching does not
need to call operating system
and to cause interrupt to the
kernel.
• in fact, the kernel knows
nothing about user level threads
and manages them as if they
Were singel-threaded process.
11. Advantages of ULT:
• User level threads does not reqquire modification to
operating system.
• Easy to represent and manage.
• User level thread can run on any operating system.
• User level threads are fast and efficient
Disadvantages of ULT:
• there is a lack of coordination between threads and operating
system kernel
• ULT require non-blocking system call.
12. Kernel Level Threads (KLT)
In this method, the
kernel knows about
and manages the
threads. No runtime
system is needed in
this case. Operating
system kernel provides
system call to create
and manage threads
13. Advantages of KLT:
• 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 of KLT:
• kernel thread are generally slower to ccreate and manage
that the user threads.
• Kernel requires Thread Control Block(TCB) for each thread in
the pool, hence complexity increases.