Servers - General
1819504 Members
3087 Online
109603 Solutions
New Discussion

Illegal instruction in pthread_join

 
meghana9490
Occasional Advisor

Illegal instruction in pthread_join

Hi Team,

I have written the wrappers from pthread, if i using the those wrappers in my repo i am getting illegal instruction in the pthread join .

I have written the pthread structure in the task.h file 

typedef struct {
    pthread_t Thread;
    char Name[THREAD_NAME_LEN];
}Task;
I created a function CommomCreateTask f
int CommonCreateTask(Value Priority, void *(*start_routine)(void ), Address StackSize, char *ThreadName, Task *T) {
                   pthread_create(&T->Thread, &attr,thread_func, &obj);
}
 
In the thread.c file I am calling the  CommonCreateTask function
 
Thread.c
int main()
{
    Task thread_id;
   
    printf("Before Thread\n");
 
      CommonCreateTask(+20, myThreadFun, 0x200, "sample_thread3", &thread_id);
     pthread_join(thread_id.Thread,NULL);
    printf("After Thread\n");
    exit(0);
}
 
After calling the wrapper function I am using pthread_join, in that I am using the  thread_id.Thread this one I am accessing from Task structure, but I am not getting any compilation error, but when i flash the code in to my hardware I am getting error illegal  instruction, can you please help me on this in ASAP
 
 
meghanagujjeti
5 REPLIES 5
meghana9490
Occasional Advisor

Re: Illegal instruction in pthread_join

Any suggesions

 

meghanagujjeti
Vinky_99
Esteemed Contributor

Re: Illegal instruction in pthread_join

Hello!

It's tuff to determine the exact cause of the illegal instruction error without additional information about your system and the specific error message. However, there are a few things you can check to help diagnose the issue:

  1. Check that the pthread library is properly linked: Make sure that your code is linking against the pthread library by adding the flag "-pthread" to your compilation command. If you're using a Makefile, you can add it to the CFLAGS variable.

  2. Check the stack size: The third parameter to pthread_create() is the stack size for the new thread. Make sure that the value you're passing is within the limits set by your system. If the stack size is too small, it can cause a stack overflow and lead to undefined behavior.

  3. Check the thread function: Make sure that the function you're passing to pthread_create() is a valid function that takes a void pointer as its argument and returns a void pointer. Also, make sure that the function doesn't use any unsupported instructions that might be causing the illegal instruction error.

  4. Check the Task structure: Make sure that the Task structure is properly defined and that the pointer you're passing to CommonCreateTask() is valid. If the pointer is invalid, it can lead to undefined behavior and cause errors.

  5. Check the hardware platform: Make sure that the hardware platform you're running your code on supports pthreads and that it meets the system requirements for the pthread library. Some embedded systems may not support pthreads or have limited support for them.

  6. Check for other errors: Check the system logs or any other error messages that may have been generated to see if there are any other issues that could be causing the illegal instruction error.

By checking these things, you may be able to identify the cause of the illegal instruction error and take steps to fix it. If you're still having trouble, providing more information about your system and the specific error message may help in diagnosing the issue further.

Let me know... 

These are my opinions so use it at your own risk.
Charles356
Frequent Visitor

Re: Illegal instruction in pthread_join

Then help may be at hand or not. We will see.

meghana9490
Occasional Advisor

Re: Illegal instruction in pthread_join

Thank you @Vinky_99 

meghanagujjeti
Herrera521
New Member

Re: Illegal instruction in pthread_join

Does any one have good suggestion?