Thread and process

What is the difference between a thread and a process?

Processes and threads are related to each other but are fundamentally different.

A process can be thought of as an instance of a program in execution. A process is an independent entity to which system resources(e.g., CPU time and memory) are allocated. Each process is executed in a separate address space, and one process cannot access the variables and data structures of another process. If a process wishes to access another process’s resource,inter-process communications have to be used. These include pipes, files, sockets, and other forms.

A thread uses the same stack space of a process, and multiple threads share parts of their states. Typically, one allows multiple threads to read and write the same memory. This is very different from processes, which cannot directly access the memory of another process. Each thread still has its own registers and its own stack, but other threads can read and write the stack memory.

A thread is a particular execution path of a process. When one thread modifies a process resources, the change is immediately visible to sibling threads.

Advertisements
This entry was posted in Threads and locks. Bookmark the permalink.

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 )

Google+ photo

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

Connecting to %s