cvs commit: src/include stdio.h src/lib/libc/gen _pthread_stubs.c src/lib/libc/stdio _flock_stub.c asprintf.c findfp.c fseek.c local.h refill.c snprintf.c sprintf.c sscanf.c ungetc.c vasprintf.c vfprintf.c vsnprintf.c vsprintf.c vsscanf.c
David Xu
davidxu at freebsd.org
Mon May 9 19:27:44 PDT 2005
Matthew Dillon wrote:
:This will require that stdio.h includes pthread.h.
:
:David Xu
Ah. Well, in that case we will have to deal with the race by enclosing
the allocation of the mutex within another, fixed mutex, and then
checking to see if the FILE's mutex is still NULL.
if (fp->blah_mutex is NULL) {
get_a_fixed_mutex(&fixed_mutex);
if (fp->blah_mutex is still NULL) {
fp->blah_mutex = malloc ....
init ....
}
rel_a_fixed_mutex(&fixed_muteX);
}
That would still be reasonably optimal. If you wanted to parallelize
it 'fixed_mutex' could be a selected mutex out of a fixed array based
on a simple hash of the FILE pointer.
-Matt
Matthew Dillon
<dillon at xxxxxxxxxxxxx>
Wasn't this already done in thread libraries ? :-)
More information about the Commits
mailing list