ivanseidel / ivanseidel/ArduinoThread
Using memory address as ThreadID sometimes gives different threads the same address
Personne n'a encore pris cette issue.
- Langage dominant
- C++
- Étoiles
- 974
- Forks
- 197
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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).
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par la fonction add de thread-controllers et la génération de ThreadID qui utilise des adresses mémoire. Reproduisez le cas avec trois threads basés sur des lambdas, en comparant leurs IDs et la taille du contrôleur avec et sans appels à Serial.println(). Le travail est terminé lorsque des threads distincts sont conservés et que le contrôleur signale systématiquement les trois.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- arduino, cpp
- Domaine
- embedded-iot
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100