Operating system : Ubuntu 11.04 \n \l
In Below Program pthread is creating new thread , but it fails when registering .
#include<pthread.h>
#include <pjlib.h>
#include <pjlib-util.h>
void serila_port_handler(void);
int main()
{
pthread_t trd_hndler;
if(pthread_create(&trd_hndler,NULL,serila_port_handler,NULL))
{
printf("ERROR while initializing serial port_thread \n");
}
pthread_join(trd_hndler,NULL);
}
void serila_port_handler(void)
{
int ret,rc;
pj_thread_desc ptd;
pj_thread_t *thread =0;
bzero(&ptd, sizeof(pj_thread_desc));
if ( (rc = pj_thread_register("serialportthread",ptd, &thread)) != PJ_SUCCESS) {
printf("Error in pj_thread_register Return Val.: %d\n",rc);
exit(1);
}
printf("pj_thread_register Success!");
sleep(10);
}
Output:
Error in pj_thread_register Return Val.: 120022
You must call pj_init() before using anyting in pj-lib.
If this still causes problems, you need to debug pj-lib, which includes figuring out what error code 120022 means, and read the source code for pj_thread_register to figure out what is happening.