Cant't run threads! 
Author Message
 Cant't run threads!

Solved : the problem was that i didn't compile well because i didn't include the -lpthread option in gcc
. The program compiled well but ran inclorrectly .
Quote:

> ?Por que si compilo y ejecuto este programa no se me inicializan bien
> los threads ?
> Why whether i compile and execute this routine threads don't inicialize
> right?

> I red all documentation and looked some examples but i can't solve this
> .
> Please help!

> /* I use threads POSIX !! */
> #define _REENTRANT
> #include <pthread.h>
> #include <thread.h>

> #include <stdio.h>
> #include <strings.h>
> #include <string.h>
> #include <stdio.h>
> #include <stdlib.h>

> void * funcionThreadLectura();
> void * funcionThreadEscritura();

> /**************************************************************************************************/

> void * funcionThreadLectura()
>   {

>    printf("soy un thread de lectura\n");
>   return NULL ;
>   }

> /**************************************************************************************************/

> void * funcionThreadEscritura()
>   {
>    printf("soy un thread de escritura\n");

>   return NULL ;

>   }

> /**************************************************************************************************/

> int main()

>  {
> thread_t threadLectura;  /* TID del thread de lectura */
> thread_t threadEscritura;  /* TID del thread de escritura */

>   int error = 0;

>    error =
> pthread_create(&threadLectura,NULL,funcionThreadLectura,NULL);
>    if (error !=0)
>     printf ("Error :%d\n" ,error);
>    else printf("OK");

>   pthread_join(threadLectura,NULL);  /* se espera a que este thread
> termine */

>    error =
> pthread_create(&threadEscritura,NULL,funcionThreadLectura,NULL);
>    if (error !=0)
>     printf ("Error :%d\n" ,error);
>    else printf("OK");

>   pthread_join(threadEscritura,NULL); /* se espera a que este thread
> termine */
>                                                              /* wait
> for  thread finish*/

>    printf("he cacabado(finished)");

>  }



Sun, 02 Mar 2003 17:03:43 GMT  
 Cant't run threads!
Solved . I didn't use the -lpthread directive to compile code .
Quote:

> ?Por que si compilo y ejecuto este programa no se me inicializan bien
> los threads ?
> Why whether i compile and execute this routine threads don't inicialize
> right?

> I red all documentation and looked some examples but i can't solve this
> .
> Please help!

> /* I use threads POSIX !! */
> #define _REENTRANT
> #include <pthread.h>
> #include <thread.h>

> #include <stdio.h>
> #include <strings.h>
> #include <string.h>
> #include <stdio.h>
> #include <stdlib.h>

> void * funcionThreadLectura();
> void * funcionThreadEscritura();

> /**************************************************************************************************/

> void * funcionThreadLectura()
>   {

>    printf("soy un thread de lectura\n");
>   return NULL ;
>   }

> /**************************************************************************************************/

> void * funcionThreadEscritura()
>   {
>    printf("soy un thread de escritura\n");

>   return NULL ;

>   }

> /**************************************************************************************************/

> int main()

>  {
> thread_t threadLectura;  /* TID del thread de lectura */
> thread_t threadEscritura;  /* TID del thread de escritura */

>   int error = 0;

>    error =
> pthread_create(&threadLectura,NULL,funcionThreadLectura,NULL);
>    if (error !=0)
>     printf ("Error :%d\n" ,error);
>    else printf("OK");

>   pthread_join(threadLectura,NULL);  /* se espera a que este thread
> termine */

>    error =
> pthread_create(&threadEscritura,NULL,funcionThreadLectura,NULL);
>    if (error !=0)
>     printf ("Error :%d\n" ,error);
>    else printf("OK");

>   pthread_join(threadEscritura,NULL); /* se espera a que este thread
> termine */
>                                                              /* wait
> for  thread finish*/

>    printf("he cacabado(finished)");

>  }



Fri, 07 Mar 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Can't create and run a modeless dialog with UI thread

2. Cant get profiler to run!

3. Cant run when build a socket project use MFC in a Static Library

4. How can i terminate a Worker Thread during a Thread is running?Thank

5. Cant see why malloc() req'd.

6. cant't link

7. Open Inventor 2.2.1 (for VC 4.2) Cant't compile in VC5.0

8. cant find Phar Lap 286 Lite structure def'n

9. Cant' add toolbar with ResourceView

10. 'Floating exception' run-time error

11. run-time error '340'

12. Can't run Prosise's Sample - hlp pls

 

 
Powered by phpBB® Forum Software