Solved

CreateThread vs CreateProcess

Posted on 2006-06-22
3
1,038 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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.

705 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