Conversation
38a6c68 to
c343b84
Compare
src/windows/osal.c
Outdated
| { | ||
| os_thread_state_t * state; | ||
|
|
||
| if (os_thread_tls_index == TLS_OUT_OF_INDEXES) |
There was a problem hiding this comment.
os_thread_tls_index is shared by all threads? At a quick glance this looks like it might not be thread-safe. Add a lock if needed or otherwise a comment to explain why locking is not needed.
There was a problem hiding this comment.
Har skrivit om detta till att använda annan allokering kopplat till kompilatorn istället så slipper vi den racen.
Dock är det lite dumt att vi inte har en osal_init() funktion. Jag blev tvungen att behålla os_thread_get_state() funktionen eftersom vi har testcase (och sannolikt verkliga användare) som anropar os_*sleep funktioner utan att vara i en os_thread(). Dvs, från main funktion.
Vi kommer läcka en os_thread_state i dessa fall då vi inte kan göra en cleanup som görs i task entry funktionen just nu. I teorin kan man använda FlsAlloc() och dess cleanup funktionallitet. Men race:et finns kvar då vi inte har någon init() funktion.
This improves accuracy compared to sleep. This make use of high resolution timers on modern windows machines to ensure timers as well as sleeps are close to 1 ms accurate, without raising the global tick interval. In theory it should allow more than 1ms accuracy however, it seem to generally be limited to around 0.6 ms in testing. Note. Requires windows 10.
This improves accuracy compared to sleep.
This make use of high resolution timers on modern
windows machines to ensure timers as well as sleeps
are close to 1 ms accurate, without raising the
global tick interval.
In theory it should allow more than 1ms accuracy
however, it seem to generally be limited to around
0.6 ms in testing.
Note. Requires windows 10.