Process VS Thread
-
Hi everybuddy, We are developing a project in which a set of various assemblies should be loaded into memory and run. We have two strategies to do that: 1. Starting each assembly code in separate thread 2. Starting each assembly code in separate process The problem is that I can't find a good reason for one of these ways, while my knowledge about important differences between 'Process' & 'Thread' is not complete. In the topic I am looking to find these answers: 1. In the case of threads, can some error in code running in one thread cause problems for execution of other assembly codes in other threads, and even prevent them from running? if yes what type of errors may cause this situation? 2. what would happen if operating system, managed all applications in set of threads instead of set of processes? Thank you so much for your note and any help --- "Art happens when you least expect it."
-
Hi everybuddy, We are developing a project in which a set of various assemblies should be loaded into memory and run. We have two strategies to do that: 1. Starting each assembly code in separate thread 2. Starting each assembly code in separate process The problem is that I can't find a good reason for one of these ways, while my knowledge about important differences between 'Process' & 'Thread' is not complete. In the topic I am looking to find these answers: 1. In the case of threads, can some error in code running in one thread cause problems for execution of other assembly codes in other threads, and even prevent them from running? if yes what type of errors may cause this situation? 2. what would happen if operating system, managed all applications in set of threads instead of set of processes? Thank you so much for your note and any help --- "Art happens when you least expect it."
Basically, there exists a relation one-to-many between processes and threads. That is, a process can host one or more threads but the inverse is not true. All the threads inside a process share the same memory space, while each different process has its own heap. Threads are in general a lighter solution that processes when you need concurrency, but not isolation of the memory space. As for your questions: 1: If one thread throws an unhandled exception your entire application should stop. In the case or processes, in one 'crashes' the others keep running. If you implement a good exception handling mechanism, using threads should not be a problem anyway. 2: Using threads inside an operating system means having all the system memory in common to all the application running inside the system. This means that every piece of code can read and write memory of other applications. In other words, applications would not be isolated, the failure on one program can lead, through memory violations, to the failure of the entire system. Also, there would be no way of preventing malicious code to write on memory areas owned by other threads. Hope this was useful
-
Basically, there exists a relation one-to-many between processes and threads. That is, a process can host one or more threads but the inverse is not true. All the threads inside a process share the same memory space, while each different process has its own heap. Threads are in general a lighter solution that processes when you need concurrency, but not isolation of the memory space. As for your questions: 1: If one thread throws an unhandled exception your entire application should stop. In the case or processes, in one 'crashes' the others keep running. If you implement a good exception handling mechanism, using threads should not be a problem anyway. 2: Using threads inside an operating system means having all the system memory in common to all the application running inside the system. This means that every piece of code can read and write memory of other applications. In other words, applications would not be isolated, the failure on one program can lead, through memory violations, to the failure of the entire system. Also, there would be no way of preventing malicious code to write on memory areas owned by other threads. Hope this was useful