Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   C threads (http://www.go4expert.com/forums/c-threads-t1362/)

sudu 7Sep2006 09:01

C threads
 
I was trying to implement threads in my C code and this is the first time I did this I used

http://www.opengroup.org/onlinepubs/...ad_create.html
and
http://www.mit.edu:8001/people/prove...c_example.html

as reference

but when I compile I get the error

:/home/shahan/engine_driver.c:43: undefined reference to `pthread_detach'
collect2: ld returned 1 exit status
make: *** [engine] Error 1

I will include the code where I create the thread

can some one help me on this

Code:

#include <pthread.h>
#include "engine.h"

void * engine_ex_comm_read(profile_t *data);
void * engine_ex_comm_write(profile_t *data);
int e_admit_engine();


int e_admit_to_engine()
{

  profile_t *this_data;
  //extern void * start_routine(void *ths_data);
  //char * this_data1;
  profile_t *new_profile;
  element_t *new_element, *new_element1;
  profile_t * loc;
  int y=0, x, ret;
  pthread_t tid;
  pthread_attr_t attr;

  while(1)
  {
      if(y!=is_buffer_emty())
      {
          this_data= read_from_buffer();

          if(this_data)
          {
            engine_ex_comm_write(this_data);
            if( pthread_create(&tid, NULL, engine_ex_comm_write, this_data))
            {
                printf("error creating thread\n");
            }
            pthread_detach(tid);
          }



All times are GMT +5.5. The time now is 07:45.