diff options
author | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2008-03-30 21:21:26 +0200 |
---|---|---|
committer | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2008-03-30 21:21:26 +0200 |
commit | e09f8d53898254c50b86e51e2915a764ec967a2d (patch) | |
tree | 0c099c679ee4bf87fd05d0672f8edb82f3e2c7c5 | |
parent | a7c0a7613a64c542c417f65b9a95e4a37c67a1bf (diff) |
Fix an initialization bug.
Use condition variables also for the kernelBO write lock.
-rw-r--r-- | src/mesa/drivers/dri/i915tex/ws_dri_bufmgr.c | 22 | ||||
-rw-r--r-- | src/mesa/glapi/glthread.h | 2 |
2 files changed, 9 insertions, 15 deletions
diff --git a/src/mesa/drivers/dri/i915tex/ws_dri_bufmgr.c b/src/mesa/drivers/dri/i915tex/ws_dri_bufmgr.c index ccbc855c55..52f29004b4 100644 --- a/src/mesa/drivers/dri/i915tex/ws_dri_bufmgr.c +++ b/src/mesa/drivers/dri/i915tex/ws_dri_bufmgr.c @@ -50,6 +50,8 @@ */ _glthread_DECLARE_STATIC_MUTEX(bmMutex); +_glthread_DECLARE_STATIC_COND(bmCond); + static int kernelReaders = 0; static drmBO *drmBOListBuf(void *iterator) @@ -235,23 +237,14 @@ static int drmBOResetList(drmBOList *list) void driWriteLockKernelBO(void) { - do { - _glthread_LOCK_MUTEX(bmMutex); - if (kernelReaders == 0) - break; - - /* - * No condition variables in Mesa yet... - */ - - _glthread_UNLOCK_MUTEX(bmMutex); - sched_yield(); - } while (1); + _glthread_LOCK_MUTEX(bmMutex); + while(kernelReaders != 0) + _glthread_COND_WAIT(bmCond, bmMutex); } void driWriteUnlockKernelBO(void) { - _glthread_UNLOCK_MUTEX(bmMutex); + _glthread_UNLOCK_MUTEX(bmMutex); } void driReadLockKernelBO(void) @@ -264,7 +257,8 @@ void driReadLockKernelBO(void) void driReadUnlockKernelBO(void) { _glthread_LOCK_MUTEX(bmMutex); - kernelReaders--; + if (--kernelReaders == 0) + _glthread_COND_BROADCAST(bmCond); _glthread_UNLOCK_MUTEX(bmMutex); } diff --git a/src/mesa/glapi/glthread.h b/src/mesa/glapi/glthread.h index 77f2fe3ad8..3962208593 100644 --- a/src/mesa/glapi/glthread.h +++ b/src/mesa/glapi/glthread.h @@ -119,7 +119,7 @@ typedef pthread_mutex_t _glthread_Mutex; typedef pthread_cond_t _glthread_Cond; #define _glthread_DECLARE_STATIC_COND(name) \ - static _glthread_Mutex name = PTHREAD_COND_INITIALIZER + static _glthread_Cond name = PTHREAD_COND_INITIALIZER #define _glthread_INIT_COND(cond) \ pthread_cond_init(&(cond), NULL) |