Solved

CreateThread vs CreateProcess

Posted on 2006-06-22
3
995 Views
Last Modified: 2012-06-27
Please check out my earlier question before reading further:
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_21895548.html

What I am debating is whether to have my NT Service Create a Thread or Create a Process.
The concern is if something goes wrong (my application logic running in say Class1 gets screwed up/blocked)  and that class is instantiated as a thread, will it be an issue to restart that thread (VAS issues?) or will it be more clean if I put my application logic in a seperate application and use CreateProcess to bring it up, so that way if something goes wrong, I will be able to terminate that process and bring it back up again.

Question = Which method is the best way to handle such clean Termination and Restart CreateThread or CreateProcess?
0
Comment
Question by:redhawk23
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 16960559
>> Which method is the best way to handle such clean Termination and Restart CreateThread or CreateProcess?

That will depend on what the app/thread should accomplish.
0
 
LVL 22

Assisted Solution

by:grg99
grg99 earned 200 total points
ID: 16961846
It depends.    Threads have lower startup overhead, but any thread can barf on the global data.

Processes can't crash and kill other proceses (mostly), but the process startup overhead is not negligible.

0
 
LVL 1

Assisted Solution

by:i_mahesh
i_mahesh earned 200 total points
ID: 16972864
If the code exdecuting in the seperate process/thread is not trustworthy and your host process needs to be robust enough to be able to recover from any non-trustworthy code problems then it would be advisable to let the non-trustworthy code run in a seperate process instead of seperate thread, in this way your host application can remain safe even something terribbly wrong happens in the child process and rcover the child process if possible but same may not be always possible if a seperate thread is opted.

Regards
Mahesh
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question