ivanseidel / ivanseidel/ArduinoThread
Using memory address as ThreadID sometimes gives different threads the same address
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C++
- Star
- 974
- Fork
- 197
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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).
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với hàm add của thread-controllers và việc tạo ThreadID sử dụng địa chỉ bộ nhớ. Tái hiện trường hợp với ba thread dựa trên lambda, so sánh các ID của chúng và kích thước của controller khi có và không có các lệnh gọi Serial.println(). Hoàn tất khi các thread khác nhau được giữ lại và controller báo cáo nhất quán cả ba thread.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- arduino, cpp
- Lĩnh vực
- embedded-iot
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100