Changeset ea28272 in mainline for uspace/lib/c/generic/fibril_synch.c
- Timestamp:
- 2010-12-30T13:43:27Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d770deb
- Parents:
- d70d80ed (diff), f418e51 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/fibril_synch.c
rd70d80ed rea28272 139 139 static void _fibril_mutex_unlock_unsafe(fibril_mutex_t *fm) 140 140 { 141 assert(fm->counter <= 0);142 141 if (fm->counter++ < 0) { 143 142 link_t *tmp; … … 165 164 void fibril_mutex_unlock(fibril_mutex_t *fm) 166 165 { 166 assert(fibril_mutex_is_locked(fm)); 167 167 futex_down(&async_futex); 168 168 _fibril_mutex_unlock_unsafe(fm); 169 169 futex_up(&async_futex); 170 } 171 172 bool fibril_mutex_is_locked(fibril_mutex_t *fm) 173 { 174 bool locked = false; 175 176 futex_down(&async_futex); 177 if (fm->counter <= 0) 178 locked = true; 179 futex_up(&async_futex); 180 181 return locked; 170 182 } 171 183 … … 230 242 { 231 243 futex_down(&async_futex); 232 assert(frw->readers || (frw->writers == 1));233 244 if (frw->readers) { 234 245 if (--frw->readers) { … … 296 307 void fibril_rwlock_read_unlock(fibril_rwlock_t *frw) 297 308 { 309 assert(fibril_rwlock_is_read_locked(frw)); 298 310 _fibril_rwlock_common_unlock(frw); 299 311 } … … 301 313 void fibril_rwlock_write_unlock(fibril_rwlock_t *frw) 302 314 { 315 assert(fibril_rwlock_is_write_locked(frw)); 303 316 _fibril_rwlock_common_unlock(frw); 317 } 318 319 bool fibril_rwlock_is_read_locked(fibril_rwlock_t *frw) 320 { 321 bool locked = false; 322 323 futex_down(&async_futex); 324 if (frw->readers) 325 locked = true; 326 futex_up(&async_futex); 327 328 return locked; 329 } 330 331 bool fibril_rwlock_is_write_locked(fibril_rwlock_t *frw) 332 { 333 bool locked = false; 334 335 futex_down(&async_futex); 336 if (frw->writers) { 337 assert(frw->writers == 1); 338 locked = true; 339 } 340 futex_up(&async_futex); 341 342 return locked; 343 } 344 345 bool fibril_rwlock_is_locked(fibril_rwlock_t *frw) 346 { 347 return fibril_rwlock_is_read_locked(frw) || 348 fibril_rwlock_is_write_locked(frw); 304 349 } 305 350 … … 314 359 { 315 360 awaiter_t wdata; 361 362 assert(fibril_mutex_is_locked(fm)); 316 363 317 364 if (timeout < 0)
Note:
See TracChangeset
for help on using the changeset viewer.