console and threads

Login to reply to this topic.
Thu, 2006-03-16 09:33
Joined: 2005-02-21
Forum posts: 47
I have a simple application which tries to use a console->Printf from another thread created by the same application. It seems not to be possible as application crashes on that with KERN-EXEC 0.

relevant part of the app itself:
LOCAL_C void doExampleL()
{
   _LIT(KHelloWorldText,"Hello TestConsole3!\n");
   console->Printf(KHelloWorldText);
   DoThreadConsoleTest();
}

void TestPrintf(const TPtrC msg);
static TInt threadFunc(TAny *data);
void DoThreadConsoleTest()
{
   RThread th;
   th.Create(_L("ConsoleTestThread"),(TThreadFunction)threadFunc,
      4096,KMinHeapSize,KMinHeapSize*2,(TAny*)NULL);
   th.Resume();
}

TInt threadFunc(TAny*)
{
   for(TInt i=0; i<25; i++)
   {
      TestPrintf(_L("I print now"));
      User::After(100*1000);
   }
   return 0;
}

void TestPrintf(const TPtrC msg)
{
   console->Printf(msg);
}


Ahti.

Thu, 2006-03-16 17:28
Joined: 2004-09-25
Forum posts: 75
Re: console and threads
It sounds like console is thread specific, like many other things in Symbian (such as most handles). I'm not surprised.

-Slava
Thu, 2006-03-16 17:31
Joined: 2005-02-21
Forum posts: 47
Re: console and threads
I certainly want to disagree what relates filehandles - by doc they are shared across process. ?

ok, have to admin, that according to a test it is not so: opened an handle in one thread, it crashed if trying to use it at another Sad

Ahti.
Thu, 2006-03-16 18:22
Joined: 2005-02-21
Forum posts: 47
Re: console and threads
I don't understand: from the SDK docs:
----
By default, any thread in the process can use this handle to access the kernel side object that the handle represents
----

But simple application crashes if thread tries to write to a file opened by another thread.
?

Ahti.
Thu, 2006-03-16 18:25
Joined: 2005-02-21
Forum posts: 47
Re: console and threads
ok, right after writing previous message I found ShareAuto() function to apply for RFs. Works now. Huh.

Ahti.
  • Login to reply to this topic.