Luca Bacci <[email protected]> wrote:

> Thanks for the review, Kirill!
>
> Yeah, that's an important issue to consider. We could work around the problem 
> by using InitializeCriticalSectionAndSpinCount (0x80000000). The API was 
> introduced in Windows 2000, which is the first OS release that delays 
> allocation of CRITICAL_SECTION events. That way only initialization can 
> throw, but that happens when the library is loaded.

One of the goals me and Pali are working toward is to port winpthreads all the 
way back to NT 3.1 and Win9x. I want changes to be systematic rather than 
various fixups here and there.

> If you think it's simpler, we can opt for
>
> union{
>   SRWLOCK srw_lock;
>   pthread_mutex_t mutex;
> };
>
> And use srw_lock if running on Vista or later. That can also help with 
> contention since a few operations only need read access.

I think using runtime checks and using newer function when available is a smart 
approach and how we should handle some things.

In another reply I mentioned that I want to have a separate file such as 
sync.c. So, what we can do is:

1. Have a `winpthreads_*` wrapper for Windows APIs we may want to use but which 
may not be available on older Windows.
2. Have a way to query whether specific functions/set of functions is available 
so other modules can make decisions at runtime based on that.

When it comes to runtime checks, I think to use the same approach I use in my 
posix32 library. This source file is a simple example: 
https://github.com/maiddaisuki/posix32/blob/master/lib/posix32-core/src/debug.c.

- Kirill Makurin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to