https://bugs.winehq.org/show_bug.cgi?id=50292
--- Comment #14 from Zebediah Figura z.figura12@gmail.com --- (In reply to Jacek Caban from comment #13)
I'm not sure how that would help, I guess that we're thinking about different implementation details. There is a global limit of threads implied by the fact that thread ids are 30 bits (a DWORD value with two least significant bit ignored). We could have tid_cache similar to fd_cache:
- in NtCreateThreadEx: ensure that tid_cache[tid >> tid_cache_shift] is
allocated and mark tid_cache[tid >> tid_cache_shift][tid & tid_cache_mask] as valid
- in NtWaitForAlertByThreadId and NtAlertThreadByThreadId: use only
tid_cache for thread-specific data
- when terminating thread: mark appropriate tid_cache as invalid
Sure. On the other hand, even for a two-tiered array like that 2**30 (times 8 or 16 bytes) is arguably a lot of storage to reserve. I don't really know what's reasonable, though.