If you want to do it properly, you need to look at the functions Logon and Rendezvous too, and take into consideration how you want it to handle stack and heap etc....
Also know that you can't use any UI functions like menues dialogs and windows from the new thread without a lot of re-initialization of stuff (and many hours headake most probably)
Nabil has already been told here and on forum Nokia that he doesn't need to use threads if active objects can be used instead. He hasn't been able to get active objects working so he's trying threads instead. Geeeeze.
Thanks all of you. I've tried what alh said and I think there is a mistake in the line in which Create is called because I have errors. Are they correct? I've looked it up and there are 3 possibilities:
- TInt Create(const TDesC &aName, TThreadFunction aFunction, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize, TAny *aPtr, TOwnerType aType=EOwnerProcess);
- TInt Create(const TDesC &aName, TThreadFunction aFunction, TInt aStackSize, RAllocator *aHeap, TAny *aPtr, TOwnerType aType=EOwnerProcess);
- TInt Create(const TDesC &aName, TThreadFunction aFunction, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize, TAny *aPtr, TOwnerType aType=EOwnerProcess);
but none of them has 5 arguments! any suggestion?
Maybe you should also brush up your C++ skills a a bit, just a friendly suggestion. Each of those functions has a last parameter with default value. Meaning, you do not need to provide that value if you are satisfied with the default one.
I love it when people try to run before they can walk, you try to tell them to slow down and learn to walk first, but they ignore you, convinced they know best and determined to run, get into difficulties running and so try to hop instead or running, but just get into more difficultites hopping, so you tell them again to learnn to walk before trying to hop but they still ignore you. Determined that if they can't run they'll try hopping, and if they can't hop then they'll skip and if they can't skip then they'll dance around merrily oblivious like a whirrling dervish on steiroids until they collapse in a heap.
ok, sorry for the stupid question .Thanks Andreas
I have an error in the create function, this line: iThreadOne.Create(_L("t1"), Exe1, KDefaultStackSize, KDefaultHeapSize,KDefaultHeapSize, NULL);
ERROR: function call '[RThread].Create(TPtrC16, int (CThread::*)(void *), {lval} const int, {lval} const unsigned int, {lval} const unsigned int, int)' does not match
Look at each parameter in turn and ask if it would compile if you assigned what you are passing as a parameter to what the compiler is telling you is expected i.e. if you had
TPtrC16 aname(_L("t1"));
...
TOwnerType atype(NULL);
etc.
Would it compile?
If these do, what about the others? Which one won't?
Hi, I've got an kern-exec 3 when i run my application. Using breakpoints I've noticed that the panic appears just after the create function. This is my code:
void CThread::StartL()
{
iThreadOne.Create( _L("t1"), Exe1, 4096, KMinHeapSize, 256*KMinHeapSize, this); //After this line I have the error
iThreadTwo.Create( _L("t2") , Exe2, 4096, KMinHeapSize, 256*KMinHeapSize, this);
iThreadOne.Resume();
iThreadTwo.Resume();
}
This panic is raised when an unhandled exception occurs. Exceptions have many causes, but the most common are access violations caused, for example, by dereferencing NULL. Among other possible causes are: general protection faults, executing an invalid instruction, alignment checks, etc.
you can search in SDK with this word "Kern-Exec 3" for more details.
Thanks & Regards
Ram
Symbian OS 9.1,S60 3rd edition MR,and CodeWarrior 3.1
My guess is you have failed to create the CThread object before you call StartL() on it, so the "this" pointer is NULL.
Only way I could think of to get a Kern-Exec 3 on that line...
That doesn't solve the problem I was suggesting....
Check the value of this in your debugger. If the value is NULL you have a big problem.
That means you called StartL() on a NULL pointer. (without creating CThread first)
That would give a kern-exec3 on the line you mention.
Forum posts: 1134
First question to ask yourself: If they do a very simple function, why do you need to complicate it with threads?
you rarely really need threads in symbian.
If you need it, then this is I guess the shortest possible code to create and run one:
TInt MyThreadFunc(TAny* aArg) { //do something } //... somewhere else: RThread t; t.Create(_L("MyThread"),MyThreadFunc,KDefaultStackSize,NULL,NULL); t.Resume();If you want to do it properly, you need to look at the functions Logon and Rendezvous too, and take into consideration how you want it to handle stack and heap etc....
Also know that you can't use any UI functions like menues dialogs and windows from the new thread without a lot of re-initialization of stuff (and many hours headake most probably)
Forum posts: 56
search for "Active Objects" they the a nice alternate for threads in symbian.
Forum posts: 132
Nabil has already been told here and on forum Nokia that he doesn't need to use threads if active objects can be used instead. He hasn't been able to get active objects working so he's trying threads instead. Geeeeze.
Forum posts: 26
Thanks all of you. I've tried what alh said and I think there is a mistake in the line in which Create is called because I have errors. Are they correct? I've looked it up and there are 3 possibilities:
- TInt Create(const TDesC &aName, TThreadFunction aFunction, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize, TAny *aPtr, TOwnerType aType=EOwnerProcess);
- TInt Create(const TDesC &aName, TThreadFunction aFunction, TInt aStackSize, RAllocator *aHeap, TAny *aPtr, TOwnerType aType=EOwnerProcess);
- TInt Create(const TDesC &aName, TThreadFunction aFunction, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize, TAny *aPtr, TOwnerType aType=EOwnerProcess);
but none of them has 5 arguments! any suggestion?
Forum posts: 586
Maybe you should also brush up your C++ skills a a bit, just a friendly suggestion. Each of those functions has a last parameter with default value. Meaning, you do not need to provide that value if you are satisfied with the default one.
Forum posts: 132
I love it when people try to run before they can walk, you try to tell them to slow down and learn to walk first, but they ignore you, convinced they know best and determined to run, get into difficulties running and so try to hop instead or running, but just get into more difficultites hopping, so you tell them again to learnn to walk before trying to hop but they still ignore you. Determined that if they can't run they'll try hopping, and if they can't hop then they'll skip and if they can't skip then they'll dance around merrily oblivious like a whirrling dervish on steiroids until they collapse in a heap.
Forum posts: 26
ok, sorry for the stupid question
.Thanks Andreas
I have an error in the create function, this line: iThreadOne.Create(_L("t1"), Exe1, KDefaultStackSize, KDefaultHeapSize,KDefaultHeapSize, NULL);
ERROR: function call '[RThread].Create(TPtrC16, int (CThread::*)(void *), {lval} const int, {lval} const unsigned int, {lval} const unsigned int, int)' does not match
Forum posts: 132
Look at each parameter in turn and ask if it would compile if you assigned what you are passing as a parameter to what the compiler is telling you is expected i.e. if you had
TPtrC16 aname(_L("t1"));
...
TOwnerType atype(NULL);
etc.
Would it compile?
If these do, what about the others? Which one won't?
Forum posts: 26
Thanks, I've forgotten to declare the Exe1 function as static!! Now this is solved.
Forum posts: 26
Hi, I've got an kern-exec 3 when i run my application. Using breakpoints I've noticed that the panic appears just after the create function. This is my code:
void CThread::StartL()
{
iThreadOne.Create( _L("t1"), Exe1, 4096, KMinHeapSize, 256*KMinHeapSize, this); //After this line I have the error
iThreadTwo.Create( _L("t2") , Exe2, 4096, KMinHeapSize, 256*KMinHeapSize, this);
iThreadOne.Resume();
iThreadTwo.Resume();
}
TInt CThread::Exe1(TAny *aPtr)(aPtr);
{
CThread* obj = static_cast
int a=3, b=5, result;
result = b-a;
return KErrNone;
}
TInt CThread::Exe2(TAny *aPtr)(aPtr);
{
CThread* obj = static_cast
RFs fsSession;
_LIT(KFileName, "C:\\thread2.txt");
return KErrNone;
}
Any idea? Thanks
Forum posts: 128
Hi,
The reasion for Kern-Exec 3 is this.
This panic is raised when an unhandled exception occurs. Exceptions have many causes, but the most common are access violations caused, for example, by dereferencing NULL. Among other possible causes are: general protection faults, executing an invalid instruction, alignment checks, etc.
you can search in SDK with this word "Kern-Exec 3" for more details.
Thanks & Regards
Ram
Symbian OS 9.1,S60 3rd edition MR,and CodeWarrior 3.1
Forum posts: 1134
My guess is you have failed to create the CThread object before you call StartL() on it, so the "this" pointer is NULL.
Only way I could think of to get a Kern-Exec 3 on that line...
Forum posts: 26
Thanks for your reply but I've got the same problem if I put 'NULL' instead of 'this'
Forum posts: 1134
That doesn't solve the problem I was suggesting....
Check the value of this in your debugger. If the value is NULL you have a big problem.
That means you called StartL() on a NULL pointer. (without creating CThread first)
That would give a kern-exec3 on the line you mention.
The reason is the simple C++ fact that this line:
under the hood, really is:
Forum posts: 25
Use the following code sample and modify your code for Create()
User::LeaveIfError(iThread.Create(KThreadName,ThreadFunc,KDefaultStackSize,KMinHeapSize,256*KMinHeapSize,iData,EOwnerThread));