Pros and Cons of Thread

A few of the advantages associated with threads are:

Parallelism:

It is nothing but executing more than one task at a time and so threads help in achieving parallelism. In the case of a multiprocessor, each thread can be executed independently by a different processor at the same time.

Responsiveness:

It adds more responsiveness to the system; if one thread is blocked, the other thread can continue to work but in the case of process, if the process is blocked the CPU goes to an idle state.

Economical:

Threads are more economical than processes in terms of creation, termination, and context switching as all threads share the same address space that is page table, signal table, open file descriptors are common among threads.

Inter-Process Communication(IPC):

IPC among threads are cheaper as all the threads share the same address space that is they share the common memory

Some of the disadvantages associated with threads are:

Robustness:

Thread-based application is less robust in comparison to process if something goes wrong even with a single thread-like memory access violation, it affects and corrupts all the threads as all threads share the common memory. This scenario leads to termination of the process abnormally.

Secure:

Threads based applications are not as secure as that of the process since all the threads share the common memory and can read and modify the shared memory easily.

Synchronization:

Thread based application has synchronization overhead since all the threads share the common memory and can read and modify the shared memory easily. Hence explicit synchronization mechanism like mutex, a semaphore is needed.

Debuggability:

Debugging a multithreaded program is difficult than a single threaded process.

Relevant Posts:



Categories: Operating system (OS)

2 replies

Trackbacks

  1. Index of Operating System - Tech Access
  2. Process vs Thread - Tech Access

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: