Bueno, gracias por la info. Ahora puse un atributo "estaVivo". Y luego, verificando la condicion de que todavia este vivo, hago un stop() y un join() en el destructor.

Ahora el tema es el siguiente... sigo teniendo problemas con la liberacion de memoria del pthread. Estuve leyendo y encontre algunas buenas definiciones:

----------
The pthread_join subroutine blocks the calling thread until the thread thread
terminates. The target thread's termination status is returned in the status
parameter.

If the target thread is already terminated, but not yet detached, the subroutine returns immediately. It is impossible to join a detached thread, even if it is not yet terminated. The target thread is automatically detached after all joined
threads have been woken up.

This subroutine does not itself cause a thread to be terminated. It acts like the
pthread_cond_wait subroutine to wait for a special condition.

The pthread_detach subroutine is used to indicate to the implementation that
storage for the thread whose thread ID is in the location thread can be reclaimed when that thread terminates. This storage shall be reclaimed on process exit,
regardless of whether the thread has been detached or not, and may include
storage for thread return value. If thread has not yet terminated, pthread_detach shall not cause it to terminate. Multiple pthread_detach calls on the same target
thread causes an error.
-------

El tema es que tanto yo, como el resto de la gente, estamos haciendo join() en nuestro desarrollo, esperando que al final de todo, se libere automaticamente la memoria ( ya que el texto dice" The target thread is automatically detached after all joined threads have been woken up."). Por lo que lei en internet, el problema esta en que valgrind te avisa que posiblemente este perdiendose memoria, pero no es asi, ya que luego, la memoria se esta liberando.

Por lo que vi, no hay una funcion directa que libere la memoria, y se pueda usar conjuntamente con el join().


Y otra cosita.... el stop(), deberia setear el estado "estoyVivo = false", o deberia ademas hacer una especie de "halt" al thread?? Porque si es esta ultima opcion, tanto las opciones pthread_cancel, como pthread_kill, como pthread_exit, no se conllevan bien luego con el uso de join(). Entonces con solo setear el atributo como falso, estaria bien, o como seria¡¡??

Muchas gracias.
Pablo Statile



_______________________________________________
Lista de correo Programacion.
[email protected]
http://listas.fi.uba.ar/mailman/listinfo/programacion

Responder a