What is the difference between processes and threads?

The memory space, where a given application is executed is called - process. A Process is the memory set aside for an application to be executed in.

Within this process the thing, which is really executed is the thread.

The key difference is that processes are fully isolated from each other; threads share (heap) memory with other threads running in the same application.

Threads share the address space of the process that created it; processes have their own address.

Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process.

Threads can directly communicate with other threads of its process; processes must use inter-process communication to communicate with sibling processes.

Threads have almost no overhead; processes have considerable overhead.

New threads are easily created; new processes require duplication of the parent process.

Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes.

4 comments:

  1. The key difference is that processes are fully isolated from each other; threads share (heap) memory with other threads running in the same application.

    ReplyDelete
    Replies
    1. Hi Vaseem,

      In debt to you for making my learning on the Linux Queries! I lay my faith on your writings.
      I have used Windows all of my life, and Mac OS X for a good chunk of it. That said, I'd like to install a Linux partition on my computer, and I wasn't sure which one to go with. I've had Fedora recommended to me, but I just don't know for sure. What is your opinion on this?
      The time to recover an ext3 file system after an unclean system shutdown does not depend on the size of the file system or the number of files; rather, it depends on the size of the journal used to maintain consistency. The default journal size takes about a second to recover, depending on the speed of the hardware.
      THANK YOU!! This saved my butt today, I’m immensely grateful.

      Merci Beaucoup,
      Kevin

      Delete
  2. Prefork Vs worker process ??

    Prefork MPM takes an Apache process and forks it into multiple identical processes, whereas Worker MPM creates multiple unique processes. In systems with 1 or 2 CPU processors, prefork is the preferred method since time is saved having the processes be more related.

    ReplyDelete
  3. On a multiprocessor system, multiple processes can be executed in parallel. Multiple threads of control can exploit the true parallelism possible on multiprocessor systems.

    Threads have direct access to the data segment of its process but a processes have their own copy of the data segment of the parent process.

    More about....Thread and Process

    Ling

    Ling

    ReplyDelete