[PATCH] Thread safe stdio
Thomas Pfaff
tpfaff@gmx.net
Thu Feb 12 20:50:00 GMT 2004
Christopher Faylor wrote:
> On Wed, Feb 11, 2004 at 11:08:57AM +0100, Thomas Pfaff wrote:
>
>>The __sinit call must be done after malloc is initialized, otherwise the
>>mutex creation will fail.
>
>
> I am not comfortable with this part of the patch. I moved the __sinit
> call where I did for a reason. It needed to be called earlier in the
> process. I'm also somewhat uncomfortable with using malloc for this
> purpose in general. It seems like a heavyweight solution to something
> that could be solved with either a muto or a critical section.
>
>
Please keep in mind that:
- There does not exist only one mutex, every file has its own that is
created on fopen and destroyed when it is closed.
- I do not call malloc directly, it is called as part of the mutex creation.
- Every mutex that is associated with an open file must be fork save, it
has to be recreated after a fork.
- _flock_t can not be a CRITICAL_SECTION nor class muto. You can not
implement newlibs _LOCK_INIT macro with this types, i have not seen
something like a CRITICAL_SECTION_INITIALIZER or a MUTO_INITIALIZER.
More information about the Cygwin-patches
mailing list