Changeset a66e2993 in mainline for uspace/lib/c/generic/fibril_synch.c
- Timestamp:
- 2010-11-05T16:16:57Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0485135, 60898b6
- Parents:
- f4057f5 (diff), 55bd76c (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
rf4057f5 ra66e2993 58 58 } 59 59 60 static bool check_for_deadlock(fibril_owner_info_t *oi)61 {62 while (oi && oi->owned_by) {63 if (oi->owned_by == (fibril_t *) fibril_get_id())64 return true;65 oi = oi->owned_by->waits_for;66 }67 68 return false;69 }70 71 60 static void print_deadlock(fibril_owner_info_t *oi) 72 61 { … … 89 78 oi = oi->owned_by->waits_for; 90 79 } 91 92 abort(); 93 } 80 } 81 82 83 static void check_for_deadlock(fibril_owner_info_t *oi) 84 { 85 while (oi && oi->owned_by) { 86 if (oi->owned_by == (fibril_t *) fibril_get_id()) { 87 print_deadlock(oi); 88 abort(); 89 } 90 oi = oi->owned_by->waits_for; 91 } 92 } 93 94 94 95 95 void fibril_mutex_initialize(fibril_mutex_t *fm) … … 113 113 link_initialize(&wdata.wu_event.link); 114 114 list_append(&wdata.wu_event.link, &fm->waiters); 115 116 if (check_for_deadlock(&fm->oi)) 117 print_deadlock(&fm->oi); 115 check_for_deadlock(&fm->oi); 118 116 f->waits_for = &fm->oi; 119 120 117 fibril_switch(FIBRIL_TO_MANAGER); 121 118 } else { … … 194 191 f->flags &= ~FIBRIL_WRITER; 195 192 list_append(&wdata.wu_event.link, &frw->waiters); 193 check_for_deadlock(&frw->oi); 194 f->waits_for = &frw->oi; 196 195 fibril_switch(FIBRIL_TO_MANAGER); 197 196 } else { … … 203 202 void fibril_rwlock_write_lock(fibril_rwlock_t *frw) 204 203 { 204 fibril_t *f = (fibril_t *) fibril_get_id(); 205 205 206 futex_down(&async_futex); 206 207 if (frw->writers || frw->readers) { 207 fibril_t *f = (fibril_t *) fibril_get_id();208 208 awaiter_t wdata; 209 209 … … 214 214 f->flags |= FIBRIL_WRITER; 215 215 list_append(&wdata.wu_event.link, &frw->waiters); 216 check_for_deadlock(&frw->oi); 217 f->waits_for = &frw->oi; 216 218 fibril_switch(FIBRIL_TO_MANAGER); 217 219 } else { 220 frw->oi.owned_by = f; 218 221 frw->writers++; 219 222 futex_up(&async_futex); … … 233 236 234 237 assert(!frw->readers && !frw->writers); 238 239 frw->oi.owned_by = NULL; 235 240 236 241 while (!list_empty(&frw->waiters)) { … … 241 246 wdp = list_get_instance(tmp, awaiter_t, wu_event.link); 242 247 f = (fibril_t *) wdp->fid; 248 249 f->waits_for = NULL; 243 250 244 251 if (f->flags & FIBRIL_WRITER) { … … 250 257 fibril_add_ready(wdp->fid); 251 258 frw->writers++; 259 frw->oi.owned_by = f; 252 260 optimize_execution_power(); 253 261 break;
Note:
See TracChangeset
for help on using the changeset viewer.