Threads- Threading Issues
Threads- Threading Issues
Issues
A thread is a single sequential flow of execution of tasks of
a process so it is also known as thread of execution or
thread of control.
Each thread has its own program counter, stack, and set of
registers. However, the threads of a single process might
share the same code and data/file. Threads are also
termed lightweight processes as they share
common resources.
Components of Thread
A thread has the following three
components:
1.Program Counter
2.Register Set
3.Stack space
Need of thread
If one thread in a program which calls fork(), does the new process
duplicate all threads, or is the new process single-threaded? If we
take, some UNIX systems have chosen to have two versions of
fork(), one that duplicates all threads and another that duplicates
only the thread that invoked the fork() system call.
If a thread calls the exec() system call, the program specified in the
parameter to exec() will replace the entire process which includes
all threads.
Signal Handling
Generally, signal is used in UNIX systems to notify
a process that a particular event has occurred.