Despite of the information that a thread must carry out in process, the process and its linked threads are diverse concept. Processes are accustomed to group resources jointly and threads are the entities scheduled for carrying out on the CPU.
A thread is a single series stream within in a process. Because threads have a few of the properties of processes, they are at times known as lightweight processes. In a process, threads permit many executions of streams. In lots of respect, threads are admired way to improve application through parallelism. The CPU switches quickly back and forth among the threads giving false impression that the threads are running in parallel.
Advantages of Threads over Multiple Processes:-
Context Switching:- Threads are very inexpensive to make and obliterate, and they are inexpensive to represent. For example, they need space to store, the PC, the SP, and the general-purpose register, but they do not need space to share memory information, Information about open files of I/O devices in use, etc. With so small context, it is much quicker to switch between threads. In extra words, it is comparatively easier for a context switch using threads.
A thread is a single series stream within in a process. Because threads have a few of the properties of processes, they are at times known as lightweight processes. In a process, threads permit many executions of streams. In lots of respect, threads are admired way to improve application through parallelism. The CPU switches quickly back and forth among the threads giving false impression that the threads are running in parallel.
Advantages of Threads over Multiple Processes:-
Context Switching:- Threads are very inexpensive to make and obliterate, and they are inexpensive to represent. For example, they need space to store, the PC, the SP, and the general-purpose register, but they do not need space to share memory information, Information about open files of I/O devices in use, etc. With so small context, it is much quicker to switch between threads. In extra words, it is comparatively easier for a context switch using threads.
Sharing:- Treads permit the sharing of a lot resources that cannot be shared in process, for example, sharing code section, information section, Operating System resources like open file etc.
Disadvantages of Threads over Multiple Processes:-
Blocking:- The main disadvantage if that if the kernel is single threaded, a system call of one thread will block the whole process and CPU may be idle during the blocking time.
Security:- Since there is, an general sharing among threads there is a potential difficulty of security. It is quite possible that one thread over write the stack of another thread (or damaged shared data) although it is very not likely since threads are meant to cooperate on a single task.
No comments:
Post a Comment