Saturday, January 5, 2013

Process and thread

A process is an executing instance of an application.
A thread is a path of execution withina process. Also, a process can contain multiple threads. When you start Word, the operating system creates a process and begins executing the primary thread of that process.
since a process can consist of multiple threads, a thread could be considered a ‘lightweight’ process.
Another difference between a thread and a process is that threads within the same process share the same address space, whereas different processes do not. This allows threads to read from and write to the same data structures and variables, and also facilitates communication between threads. Communication between processes – also known as IPC, or inter-process communication – is quite difficult and resource-intensive.
Each process has it’s own address space, but the threads within the same process share that address space. Threads also share any other resources within that process. This means that it’s very easy to share data amongst threads, but it’s also easy for the threads to step on each other, which can lead to bad things.

So, what is the difference between multiple processesand multiple threads? The essential
difference is that while each process has a complete set of its own variables, threads
share the same data.
individual programs will appear to do multiple tasks at the same time. Each task is usu-ally called a thread—which is short for thread of control.

No comments:

Post a Comment