Whether should i use processes or threads in Linux?

By -

While designing any system usually we might confuse between thread and process usage . We think should we use thread or process for our requirement. Which will be the best choice.?


So Here are some guidelines to help you……



  • All threads inside a program always run from the same executable binary. Where a child process , may run a from different executable binary by calling an exec function.
  • If one process crashes or has a buffer overrun, it does not affect any other process at all, whereas if a thread crashes, it takes down all of the other threads in the process because threads share the same virtual memory space and other resources.
  • Threads should be used for programs that need fine-grained parallelism. For example, if a problem can be broken into multiple, nearly identical tasks, threads may be a good choice. Processes should be used for programs that need coarser parallelism.
  • Sharing data among threads is quite easy because threads share the same memory. Sharing data among processes needs to  the use of IPC mechanisms which is quite complex.
  •  Processes are more heavy-weight than threads, and have a higher start up and shutdown cost. Interprocess communication (IPC) is also harder and slower than inter-thread communication.


Note : There is also some discussion about saying t in Windows processes are heavy and expensive compared to threads, and in Linux the difference is much smaller.

hey I am an Artist who love to write code...! Well I am an EC graduate From Ganpat University and now i am working as Embedded software engineer in one private firm.. find me at here Jeegar Patel

3 Comments to Whether should i use processes or threads in Linux?

    • exec() : The exec call is a way to basically replace the entire current process with a new program. It loads the program into the current process space and runs it from the entry point.

      clone() : to understand this you need to understand the concept of fork()
      see fork call basically makes a duplicate of the current process, identical in almost every way (not everything is copied over, for example, resource limits in some implementations but the idea is to create as close a copy as possible).

      where clone is something differ
      Clone, as fork, creates a new process. but these calls allow the child process to share parts of its execution context with the calling process, such as the memory space, the table of file descriptors, and the table of signal handlers.So here IPC calls make easily

      i hope you get it but dont worry very soon i will write one article for clearing all such confusion about those system call …right now i am also working with such things..!!!

Leave a Reply

Your email address will not be published. Required fields are marked *