Changeset b0a76d5 in mainline
- Timestamp:
- 2010-12-21T15:23:31Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c81b6f2
- Parents:
- be942bc
- Location:
- uspace/lib/c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/fibril_synch.c
rbe942bc rb0a76d5 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; 304 343 } 305 344 … … 314 353 { 315 354 awaiter_t wdata; 355 356 assert(fibril_mutex_is_locked(fm)); 316 357 317 358 if (timeout < 0) -
uspace/lib/c/include/fibril_synch.h
rbe942bc rb0a76d5 105 105 extern bool fibril_mutex_trylock(fibril_mutex_t *); 106 106 extern void fibril_mutex_unlock(fibril_mutex_t *); 107 extern bool fibril_mutex_is_locked(fibril_mutex_t *); 107 108 108 109 extern void fibril_rwlock_initialize(fibril_rwlock_t *); … … 111 112 extern void fibril_rwlock_read_unlock(fibril_rwlock_t *); 112 113 extern void fibril_rwlock_write_unlock(fibril_rwlock_t *); 114 extern bool fibril_rwlock_is_read_locked(fibril_rwlock_t *); 115 extern bool fibril_rwlock_is_write_locked(fibril_rwlock_t *); 113 116 114 117 extern void fibril_condvar_initialize(fibril_condvar_t *);
Note:
See TracChangeset
for help on using the changeset viewer.