answersLogoWhite

0


Best Answer

You use a process when you want a separate program, and a thread when you want to asynchronously execute some different code contained within the same program.

A process is an address space containing instructions, data, stack, etc. It represents one load module (or program) loaded into memory, ususally by the operating system's exec or equivalant call.

There can be more than one process loaded from the same load module. They are separate and distinct, even though they might share regions of instructions and constant data. As an example, the execution of ksh (in linux) or cmd (in windows) represents a process.

While executing, a process can invoke another process, either a copy of itself or a different one. For example, ksh can invoke ls, and cmd can invoke explorer. Keep in mind that this is still a different address space. In the case of linux, the process actually makes a copy of itself (fork) and then overlays itself with the new load module.

A thread, on the other hand is an execution path through a process. Every process has at least one thread, which starts with the first instruction it executes after being loaded, and ends with the call to the exit or equivalent operating system call.

So, to clarify, what executes is actually called a thread, and the process is just the address space. Different naming conventions do exist - this is the windows (and some other OS's) convention.

{Restating from three paragraphs before} While executing, a thread can load another process, either a copy of its containing process or a different one, or it can invoke a new thread within itself. While the difference might seem slight, it is not, because the (now two) threads share the same address space, and they can easily communicate with each other, assuming appropriate synchronization is used.

In the case of linux, you could say that a separate process is started as fork followed by overlay, while a new thread started as fork without the overlay.

Each thread has its own copy of its local variables, and a copy of the invoking parameters. In the simple case, that is sufficient. In the more complex case, involving explicitly allocated heap memory, either different heaps are used, or a mechanism for synchronized sharing is implemented.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Multiple processes can take advantage of true parallelism when multiple processors are involved. Normally, two threads running in the same process must run on the same physical processor. Change those threads to processes, however, and you can have them each running on a separate processor in parallel.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why use multiple processes instead of multiple threads?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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. A great answer to the question can also be found here: (link moved to link section)


Why is single thread system not used in java?

Because the developers of Java considered the possibility of multithreading a big advantage. You don't HAVE TO use multiple threads; just use it when you need it.Because the developers of Java considered the possibility of multithreading a big advantage. You don't HAVE TO use multiple threads; just use it when you need it.Because the developers of Java considered the possibility of multithreading a big advantage. You don't HAVE TO use multiple threads; just use it when you need it.Because the developers of Java considered the possibility of multithreading a big advantage. You don't HAVE TO use multiple threads; just use it when you need it.


What is the purpose of Java sleep?

It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.


Can a multithread solution using multiple user level threads achieve better performance on a multiprocessor system than on a single processor system?

A multithreaded system comprising of multiple user-levelthreads cannot make use of the different processors in a multiprocessorsystem simultaneously. The operating system sees only a single processand will not schedule the different threads of the process on separateprocessors. Consequently, there is no performance benefit associatedwith executing multiple user-level threads on a multiprocessor system.


What is the difference between Light-weight process and heavyweight process?

Light weight process are the process are the processes which is considered for the os as less burden like thread.means the threads are executing inside a process which share the same code and data also memory space of a single process that's it has a less burden to the os and considered as a light weight process.also the communication between the threads are much more efficient. where as in case of a heavy weight process for doing multiple task the os has to create multiple processes which have a multiple memory address space and for communication between them they have to use inter process communication using sockets and pipe and which has more burden on the os than the threads(ligt weight processes) and hence considered as a heavy weight process

Related questions

What can thread make?

In computer programming, you can use multiple threads if you want the computer to do several things at the same time.In computer programming, you can use multiple threads if you want the computer to do several things at the same time.In computer programming, you can use multiple threads if you want the computer to do several things at the same time.In computer programming, you can use multiple threads if you want the computer to do several things at the same time.


The support and use of multiple processors to handle multiple threads is known as?

multiprocessing


What is the support and use of multiple processors to handle multiple threads known as?

multiprocessing


What is The support and use of multiple processors to handle multiple threads is known as?

multiprocessing


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. A great answer to the question can also be found here: (link moved to link section)


Why is single thread system not used in java?

Because the developers of Java considered the possibility of multithreading a big advantage. You don't HAVE TO use multiple threads; just use it when you need it.Because the developers of Java considered the possibility of multithreading a big advantage. You don't HAVE TO use multiple threads; just use it when you need it.Because the developers of Java considered the possibility of multithreading a big advantage. You don't HAVE TO use multiple threads; just use it when you need it.Because the developers of Java considered the possibility of multithreading a big advantage. You don't HAVE TO use multiple threads; just use it when you need it.


What is a multiple generator?

Multiple generators are when you use several smaller generators instead of one larger one. For example, you might use multiple 10Kw generators instead of one 30Kw generator.


Briefly summarise the reasons for the decisions made by software developers regarding the use of processes versus threads?

Control and speed of executions.


What are other words to use instead of steps?

phases, levels, processes, points.


What is the purpose of Java sleep?

It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.


Can a multithread solution using multiple user level threads achieve better performance on a multiprocessor system than on a single processor system?

A multithreaded system comprising of multiple user-levelthreads cannot make use of the different processors in a multiprocessorsystem simultaneously. The operating system sees only a single processand will not schedule the different threads of the process on separateprocessors. Consequently, there is no performance benefit associatedwith executing multiple user-level threads on a multiprocessor system.


When to use threads in program?

You use threads whenever you want your program to do several things simultaneously.You use threads whenever you want your program to do several things simultaneously.You use threads whenever you want your program to do several things simultaneously.You use threads whenever you want your program to do several things simultaneously.