Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CreateThread vs CreateProcess

Posted on 2006-06-22
3
Medium Priority
?
1,088 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 300 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 600 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 600 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

Technology Partners: 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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

618 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