thread
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > thread




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    thread  
jessie


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Re: thread  
Amphibient


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-08-05 11:29 PM

Is your gdb able to handle threads? this is probably the issue...

Also,

main() is historically declared in one of the following ways:

int main(void) {} <- I think you mean this
int main(int argc, char *argv[]) {} <- standard

for _ti_bind_guard info, check out:
http://cvs.opensolaris.org/source/x... />
bind_guard






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 02:59 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register