What is the Difference between Process and Thread ?

Creating a new thread is very similar to forking a new process, but there are differences.

  • When a new process is forked, it shares relatively little data with the parent process which created it, when a new thread is created, it shares much more information (such as all the global variables and static local variables, the open files, and the process ID).
  • The overhead of creating separate copies of everything makes the creation of a new process slower than the creation of a new thread.
  • And the time it takes to pass control from one process to another (a context switch) is longer than the time required to pass control from one thread to another.
  • Since the threads share their data space, passing information from one thread to another is much more straightforward than passing information from one process to another—while this does have its own problems, it need not be difficult if a little care is taken.
Related :   Go Program : Identify total number of network interfaces and display the details using index

When a process is created using fork, a new copy of the process is created with its own variables and its own PID. This new process is scheduled independently, and executes almost independently of the process that created it.

When a new thread is created in a process, the new thread of execution gets its own stack (and hence local variables) but shares global variables, file descriptors, signal handlers, and its current directory state with the process that created it.

You may like to read :

Creating a simple thread in Linux using pthread library api’s and How to create process in Linux using fork system call ?

Reference : linuxjournal.com


Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )


Leave a Comment

Android Android Applications Android Build system Android Commands Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded