Changes in uspace/lib/c/generic/fibril_synch.c [84b7384:63f8966] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/fibril_synch.c
r84b7384 r63f8966 42 42 #include <errno.h> 43 43 #include <assert.h> 44 #include <stacktrace.h>45 #include <stdlib.h>46 44 47 45 static void optimize_execution_power(void) … … 58 56 } 59 57 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 static void print_deadlock(fibril_owner_info_t *oi)72 {73 fibril_t *f = (fibril_t *) fibril_get_id();74 75 printf("Deadlock detected.\n");76 stacktrace_print();77 78 printf("Fibril %p waits for primitive %p.\n", f, oi);79 80 while (oi && oi->owned_by) {81 printf("Primitive %p is owned by fibril %p.\n",82 oi, oi->owned_by);83 if (oi->owned_by == f)84 break;85 stacktrace_print_fp_pc(context_get_fp(&oi->owned_by->ctx),86 oi->owned_by->ctx.pc);87 printf("Fibril %p waits for primitive %p.\n",88 oi->owned_by, oi->owned_by->waits_for);89 oi = oi->owned_by->waits_for;90 }91 92 abort();93 }94 95 58 void fibril_mutex_initialize(fibril_mutex_t *fm) 96 59 { 97 fm->oi.owned_by = NULL;98 60 fm->counter = 1; 99 61 list_initialize(&fm->waiters); … … 102 64 void fibril_mutex_lock(fibril_mutex_t *fm) 103 65 { 104 fibril_t *f = (fibril_t *) fibril_get_id();105 106 66 futex_down(&async_futex); 107 67 if (fm->counter-- <= 0) { … … 113 73 link_initialize(&wdata.wu_event.link); 114 74 list_append(&wdata.wu_event.link, &fm->waiters); 115 116 if (check_for_deadlock(&fm->oi))117 print_deadlock(&fm->oi);118 f->waits_for = &fm->oi;119 120 75 fibril_switch(FIBRIL_TO_MANAGER); 121 76 } else { 122 fm->oi.owned_by = f;123 77 futex_up(&async_futex); 124 78 } … … 132 86 if (fm->counter > 0) { 133 87 fm->counter--; 134 fm->oi.owned_by = (fibril_t *) fibril_get_id();135 88 locked = true; 136 89 } … … 146 99 link_t *tmp; 147 100 awaiter_t *wdp; 148 fibril_t *f;149 101 150 102 assert(!list_empty(&fm->waiters)); … … 153 105 wdp->active = true; 154 106 wdp->wu_event.inlist = false; 155 156 f = (fibril_t *) wdp->fid;157 fm->oi.owned_by = f;158 f->waits_for = NULL;159 160 107 list_remove(&wdp->wu_event.link); 161 108 fibril_add_ready(wdp->fid); 162 109 optimize_execution_power(); 163 } else {164 fm->oi.owned_by = NULL;165 110 } 166 111 } … … 175 120 void fibril_rwlock_initialize(fibril_rwlock_t *frw) 176 121 { 177 frw->oi.owned_by = NULL;178 122 frw->writers = 0; 179 123 frw->readers = 0;
Note:
See TracChangeset
for help on using the changeset viewer.