Solved

CreateThread vs CreateProcess

Posted on 2006-06-22
3
1,016 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

726 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