- Timestamp:
- Jun 9, 2009 10:21:09 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/freebsd/semevent-r0drv-freebsd.c
r20208 r20448 76 76 pEventInt->cWaking = 0; 77 77 pEventInt->fSignaled = 0; 78 mtx_init(&pEventInt->Mtx, "IPRT Event Semaphore", NULL, MTX_SPIN);78 mtx_init(&pEventInt->Mtx, "IPRT Event Semaphore", NULL, 0); 79 79 *pEventSem = pEventInt; 80 80 return VINF_SUCCESS; … … 94 94 VERR_INVALID_HANDLE); 95 95 96 mtx_lock _spin(&pEventInt->Mtx);96 mtx_lock(&pEventInt->Mtx); 97 97 ASMAtomicIncU32(&pEventInt->u32Magic); /* make the handle invalid */ 98 98 if (pEventInt->cWaiters > 0) … … 101 101 ASMAtomicXchgU32(&pEventInt->cWaking, pEventInt->cWaking + pEventInt->cWaiters); 102 102 wakeup(pEventInt); 103 mtx_unlock _spin(&pEventInt->Mtx);103 mtx_unlock(&pEventInt->Mtx); 104 104 } 105 105 else if (pEventInt->cWaking) 106 106 /* the last waking thread is gonna do the cleanup */ 107 mtx_unlock _spin(&pEventInt->Mtx);107 mtx_unlock(&pEventInt->Mtx); 108 108 else 109 109 { 110 mtx_unlock _spin(&pEventInt->Mtx);110 mtx_unlock(&pEventInt->Mtx); 111 111 mtx_destroy(&pEventInt->Mtx); 112 112 RTMemFree(pEventInt); … … 125 125 VERR_INVALID_HANDLE); 126 126 127 mtx_lock _spin(&pEventInt->Mtx);127 mtx_lock(&pEventInt->Mtx); 128 128 129 129 if (pEventInt->cWaiters > 0) … … 136 136 ASMAtomicXchgU8(&pEventInt->fSignaled, true); 137 137 138 mtx_unlock _spin(&pEventInt->Mtx);138 mtx_unlock(&pEventInt->Mtx); 139 139 return VINF_SUCCESS; 140 140 } … … 150 150 VERR_INVALID_HANDLE); 151 151 152 mtx_lock _spin(&pEventInt->Mtx);152 mtx_lock(&pEventInt->Mtx); 153 153 154 154 if (pEventInt->fSignaled) … … 173 173 ASMAtomicIncU32(&pEventInt->cWaiters); 174 174 175 mtx_unlock_spin(&pEventInt->Mtx); 176 /** @todo r=bird: This doesn't handle cMillies == 0 correctly, it will assert 177 * and or sleep for ever according to r47861. (That's probably an old bug 178 * of my making.) 179 * 180 * And it really looks like it's racing signalling on MP systems. (It 181 * *looks* like you leave the lock and then tries to go to sleep on a 182 * block id, someone spinning on the lock attempt to wake us up before we 183 * go to sleep. That's why the code was originally trying to use msleep 184 * here.). */ 185 rc = tsleep(pEventInt, /* block id */ 186 fInterruptible ? PZERO | PCATCH : PZERO, 187 "iprtev", /* max 6 chars */ 188 cMillies == RT_INDEFINITE_WAIT 189 ? 0 190 : tvtohz(&tv)); 191 mtx_lock_spin(&pEventInt->Mtx); 175 /** @todo r=bird: This doesn't handle cMillies == 0 correctly, it will assert 176 * and or sleep for ever according to r47861. (That's probably an old bug 177 * of my making.) 178 */ 179 rc = mtx_sleep(pEventInt, /* block id */ 180 &pEventInt->Mtx, /* mtx */ 181 fInterruptible ? PZERO | PCATCH : PZERO, 182 "iprtev", /* max 6 chars */ 183 cMillies == RT_INDEFINITE_WAIT 184 ? 0 185 : tvtohz(&tv)); 192 186 193 187 switch (rc) … … 207 201 /* The event was destroyed, as the last thread do the cleanup. 208 202 we don't actually know whether */ 209 mtx_unlock _spin(&pEventInt->Mtx);203 mtx_unlock(&pEventInt->Mtx); 210 204 mtx_destroy(&pEventInt->Mtx); 211 205 RTMemFree(pEventInt); … … 237 231 } 238 232 239 mtx_unlock _spin(&pEventInt->Mtx);233 mtx_unlock(&pEventInt->Mtx); 240 234 return rc; 241 235 }
Note:
See TracChangeset
for help on using the changeset viewer.