Is it safe to cast the osThreadId pointer to a 32-bit integer for a unique thread ID across platform
Hey friends, Porting a product to a CMSIS RTOS. We need a 32-bit integer representing the thread ID. While is opaque, comments suggest it's a pointer. Is it safe to cast the pointer to a 32-bit integer for a unique thread ID across platforms? Why or why not?
@Middleware & OS
Solution:Jump to solution
Hi @Dtynin , Casting a
osThreadId
pointer to a 32-bit integer is generally not safe and should be avoided, instead you can try maintain a mapping or using a 64-bit Integer.
this is how your code should look like for maintaining a map 👇
```c...2 Replies
Solution
Hi @Dtynin , Casting a
osThreadId
pointer to a 32-bit integer is generally not safe and should be avoided, instead you can try maintain a mapping or using a 64-bit Integer.
this is how your code should look like for maintaining a map 👇
This might be helpful
https://developer.arm.com/documentation/ka003944/latest/