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: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 May 2005 18:43:11 -0700 (PDT)

: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@xxxxxxxxxxxxx>



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