DragonFly BSD
DragonFly commits List (threaded) for 2005-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: 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

From: David Xu <davidxu@xxxxxxxxxxx>
Date: Tue, 10 May 2005 10:27:44 +0800

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) {
	if (fp->blah_mutex is still NULL) {
	    fp->blah_mutex = malloc ....
	    init ....

    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.

Matthew Dillon <dillon@xxxxxxxxxxxxx>
Wasn't this already done in thread libraries ? :-)

[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]