Reserve TID values for WASI threads#1862
Reserve TID values for WASI threads#1862wenyongh merged 3 commits intobytecodealliance:dev/wasi_threadsfrom
Conversation
…abstract data type
a099bb7 to
74602bf
Compare
| if (tid_allocator->ids == NULL) | ||
| return NULL; | ||
|
|
||
| for (int64 i = tid_allocator->pos - 1; i >= 0; i--) |
There was a problem hiding this comment.
but tid_allocator->pos is uint32, it may not fit into int32
There was a problem hiding this comment.
pos - 1 is <= 0x1fffffff and can always be represented by an int32, can't it?
There was a problem hiding this comment.
I was keeping it generic, so that we're safe if we decide to change the maximum id in the future (allowing the first leftmost bit to be different from 0)
|
|
||
| #include "platform_common.h" | ||
|
|
||
| #define TID_ALLOCATOR_INIT_SIZE CLUSTER_MAX_THREAD_NUM |
There was a problem hiding this comment.
This is only used in tid_allocator.c, so I'd suggest defining it there; if there's a need to use it in other places in the future, we can move it back here.
There was a problem hiding this comment.
As for TID_MIN and TID_MAX, I put it in the header since they are some parameters we can change to alter the behavior of the id allocator without looking into the .c implementation
98faf6c to
3465b8a
Compare
According to the [WASI thread specification](WebAssembly/wasi-threads#16), some thread identifiers are reserved and should not be used. In fact, only IDs between `1` and `0x1FFFFFFF` are valid. The thread ID allocator has been moved to a separate class to avoid polluting the `lib_wasi_threads_wrapper` logic.
According to the WASI thread specification, some thread identifiers are reserved and should not be used. In fact, only IDs between
1and0x1FFFFFFFare valid.The thread ID allocator has been moved to a separate class to avoid polluting the
lib_wasi_threads_wrapperlogic.