Thread Libraries& Threads Issues
Thread Libraries& Threads Issues
Thread Library is a thread API (Application programming Interface) which is a set of functions,
methods and routine provided by operating system for creating, managing and coordination of the
threads.
Thread Libraries may be implemented either in user space or Kernel Space Library.
If the thread Library is implemented at a user space then the code and information of thread
Library world be reside in user Space in this scenario invoking any function from thread
Library would be simple function Call and can’t be a system call.
But if the thread Library is implemented at the Kernel space then the code and information
of thread boy Would be reside in kernel mode space and supported by operating system, in
this scenario invoking any from thread Library would be System function Call to the kernel
There are lots of thread Libraries available, but some of them are widely used. Some of
they are
1. Java thread
2. P Thread
3. Win32thread
JAVA THREAD:
1. Thread is a primary model of program execution in Tam program and Tara Language
and It's Aps provides a rich Variety of features for the Creation and the management
of threads. As name significance that it's cook written in Java Language.
2. However in most instances the JVM (JAVA VIRTUVAL MCAHINE) is running on top of
host operating system the Java thread App typically implemented using thread
Library a variable on the host system, which signifies that an window system the java
thread implemented through WIN32API.
3. It provide built-in support for multi-threading through Java. Long thread.
PTHREAD
1. It is also known as posix thread, it's an execution model that exists independently
from a programming language as well as a parallel model.
2. P-thread Library can be implemented either at the user space or kernel space.
3. The P thread is often implemented at the UNIX, Linux and Solaris, and it is highly
portable as it code written in p thread can typically be compiled and run on different
UNIX without much modifications.
Features of P THERAD
1. Thread – ID: if it is null then no thread is returned.
2. Attribute: Attributes of Threads, if it is null then no attributes are assigned.
3. Arguments: the actual argument by default value passed during execution.
4. Return value: it is integer then it returns zero on success and value 1 on failure.
Functions of P THERAD
1. P THERAD EXIT(): Terminates the current functions
2. P THREAD KILL (): Used to send the specified thread to terminate.
Win32 thread
4. They providing native and low level support for multi-threading. It means
they are tightly integrated with window OS and offer efficient creation and
thread management.
THREAD ISSUES:
Threading Issues in OS
System Call
Thread Cancellation
Signal Handling
Thread Pool
Thread Specific Data
Thread cancellation is nothing but killing the thread & terminate the thread.
Thread cancellation is the task of terminating a thread before it has completed.
So, let’s take a look at an example to make sense of it. Suppose, there is a
multithreaded program whose several threads have been given the right to scan a
database for some information. The other threads however will get canceled once
one of the threads happens to return with the necessary results.
The target thread is now the thread that we want to cancel. Thread cancellation
can be done in two ways:
Asynchronous Cancellation: The asynchronous cancellation involves only
one thread that cancels the target thread immediately.
Signal Handling
Signal in Linux there are several signals which are useful in order to
send notifications to the processes, depending on the problem it can handle the
threads.
THREAD POOL:
Collection of threads can be called as a thread pool.
Client Sends request to Web Server, Webserver request the to handle the
responsibilities of Clint request threads.
It allocates a request to a thread how it is the responsibility of T1 to handle that
requests it will message one more run then it is the responsibility of T2, T3
….Tn In order to handle the Web Sever. Needs to create one lakh threads. So it
is a burden of the web server by the time pool consists of 1 lakh threads. So that
it can assign all the responsibilities of client request assign to existing 1 lakh
threads.