Solved

CreateThread vs CreateProcess

Posted on 2006-06-22
3
967 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
Comment Utility
>> 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 clear a vector as well as how to detect empty vectors in C++.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now