ivanseidel / ivanseidel/ArduinoThread

Using memory address as ThreadID sometimes gives different threads the same address

Abierto
#42 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C++
Estrellas
974
Forks
197
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

In my program, I've created 3 threads and then added them all to a controller thread. However, one thread was never executed (I had print-statements that should have run) and after some debugging I noticed that the size of the controller thread showed 2, when it should have been 3. I did not use thread names. I am only using lambda functions as callback functions for the threads.

Looking at the thread-controllers add function, I saw that a thread is not added when the controller already has a thread with the same ID. I printed the thread-ids of all my threads and it turned out that the 1st and the 3rd thread got the same ID, so the 3rd thread was never added. But this should not be possible as different threads should get different ids?

When I added Serial.println() before and Serial.println(controller.size()) after adding the 3rd thread to the controller, all 3 threads got different IDs. I can not explain this behaviour.

Thus, my conclusion is that using memory address as ThreadID feels unpredictable. Maybe thread id could be substituted by a random number instead? (I did this as a workaround).

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Comienza con la función add de thread-controllers y la generación de ThreadID que utiliza direcciones de memoria. Reproduce el caso con tres hilos basados en lambdas, comparando sus IDs y el tamaño del controlador con y sin llamadas a Serial.println(). Se considera terminado cuando se conservan hilos distintos y el controlador informa de los tres de forma consistente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
arduino, cpp
Área
embedded-iot
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.