In my program, I would like to create two threads, each running in a different process. My program is in a single exe. I can create two threads in the same process with no trouble, using RThread.Create() and passing in the different thread functions. The RProcess.Create() requires that I load my code from a DLL or EXE on the file system.
Does anybody know how I can create a thread from within my exe that runs in its own process...seperate from the exe... without having to create another exe to support it?
May seem like a strange question :-) .. oh BTW, I am using Series 60 SDK with FP1.
By default, ownership of this thread handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.
Here parameter TOwnerType aType .....is an enumeration whose enumerators define the ownership of this thread handle. If not explicitly specified, EOwnerProcess is taken as default.
Have a look at changing the owner of the thread;so,one process cant interrupt other thread(with different process owner).
Thanks for your response. I had looked at the SDK docs... the issue that I was running into was that if I use EOwnerProcess, I can create a thread that is owned by the process...if I use EOwnerThread, then the thread is owned by the thread that created it... what I wanted was to create a thread that would be owned by a new process...different from the one that I am currently running in... do you know if this is possible?
What I am really trying to do is create a sort of watchdog thread/process that will restart a server if the server terminates. I was thinking that they both should be in different processes so as to protect the watchdog should the server process terminate... maybe this is not so important... so.. if I created an EOwnerProcess watchdog thread and an EOwnerProcess server thread... would the watchdog continue to execute if the server thread died for some reason?
Hi erneykm,
You can create the two threads in a single process and start the server thread from the other thread if it terminates. I haven't tested this and just giving an idea and let me know if it works or if u have implemented it in anyother way.
Thanks for the idea. I have implemented it as you suggest. I created a process loaded from one exe and created two process owned threads. One thread is the watchdog and the other one is the server. The watchdog runs an AO that waits for notification of thread death and restarts another thread if it dies.
So far it works really well. I am currently looking at what memory protection is provided... it was my understanding that threads in the same process can scribble on eachothers memory... which could potentially cause my server to cause an exception in the watchdog thread... this I did not want, but may be okay.
Any ideas on how to protect the memory of one thread from another in the same process?
PushL ... thanks for the feedback. Do you know of a non-public API that would allow this....meaning that if I had access to a devkit would using a non-public api be supported on a given production device? Can you think of an area that I should examine?
I pressume the best way is asking Symbian or Nokia about this issues. Certainly you'd need to have some certainty before disbursing that money on a devkit.