11-05-05 01:50 AM
I have the following code. It can be compiled throught. but when I debug
(gdb) it show a error 0xfefda6b0 in _ti_bind_guard () from
/usr/lib/libthread.so.1
. I used g++ test4.cpp -g -lpthread -o test4 to compile.
please help
Thanks
#define _REENTRANT
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <sys/uio.h>
#include <unistd.h>
#include <thread.h>
#include <netdb.h>
/* the TCP port that is used for this example */
#define TCP_PORT 3001
/* function prototypes and global variables */
void *do_listen(void *);
void *do_timer(void *);
mutex_t lock;
int service_count;
main()
{
int sockfd, newsockfd, clilen, ret;
struct sockaddr_in cli_addr, serv_addr;
thread_t chld_thr, chld_thr1, chld_thr2, chld_thr3, chld_thr4, chld_thr5,
chld_thr6;
thr_create(NULL, 0, do_timer, (void *) NULL, THR_DETACHED, &chld_thr1);
thr_create(NULL, 0, do_listen, (void *) NULL, THR_DETACHED, &chld_thr);
return(0);
}
void *do_timer(void *arg)
{
for(;;){
sleep (3);
mutex_lock(&lock);
service_count++;
printf("Child thread [%d]: service_count [%d]\n", thr_self(),
service_count );
mutex_unlock(&lock);
}
}
void *do_listen(void *arg)
{
for(;;){
printf("do listen [%d]: Socket number = %d\n", thr_self());
}
}
[ Post a follow-up to this message ]
|