Changes in / [e503d3a9:b14b71e] in mainline


Ignore:
Location:
uspace/lib/c
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/abs32le/include/fibril.h

    re503d3a9 rb14b71e  
    4444                (ctx)->pc = (uintptr_t) (_pc); \
    4545                (ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \
    46                 (ctx)->fp = 0; \
    4746                (ctx)->tls = ((uintptr_t) (ptls)) + sizeof(tcb_t); \
    4847        } while (0)
     
    5453typedef struct {
    5554        uintptr_t sp;
    56         uintptr_t fp;
    5755        uintptr_t pc;
    5856        uintptr_t tls;
    5957} context_t;
    60 
    61 static inline uintptr_t context_get_fp(context_t *ctx)
    62 {
    63         /* On real hardware, this function returns the frame pointer. */
    64         return ctx->fp;
    65 }
    6658
    6759#endif
  • uspace/lib/c/arch/amd64/include/fibril.h

    re503d3a9 rb14b71e  
    5656 */
    5757typedef struct {
    58         uint64_t sp;
    59         uint64_t pc;
     58    uint64_t sp;
     59    uint64_t pc;
     60   
     61    uint64_t rbx;
     62    uint64_t rbp;
    6063
    61         uint64_t rbx;
    62         uint64_t rbp;
     64    uint64_t r12;
     65    uint64_t r13;
     66    uint64_t r14;
     67    uint64_t r15;
    6368
    64         uint64_t r12;
    65         uint64_t r13;
    66         uint64_t r14;
    67         uint64_t r15;
    68 
    69         uint64_t tls;
     69    uint64_t tls;
    7070} context_t;
    71 
    72 static inline uintptr_t context_get_fp(context_t *ctx)
    73 {
    74         return ctx->rbp;
    75 }
    7671
    7772#endif
  • uspace/lib/c/arch/arm32/include/fibril.h

    re503d3a9 rb14b71e  
    8686} context_t;
    8787
    88 static inline uintptr_t context_get_fp(context_t *ctx)
    89 {
    90         return ctx->fp;
    91 }
    92 
    9388
    9489#endif
  • uspace/lib/c/arch/ia32/include/fibril.h

    re503d3a9 rb14b71e  
    6767} context_t;
    6868
    69 static inline uintptr_t context_get_fp(context_t *ctx)
    70 {
    71         return ctx->ebp;
    72 }
    73 
    7469#endif
    7570
  • uspace/lib/c/arch/ia64/include/fibril.h

    re503d3a9 rb14b71e  
    130130} context_t;
    131131
    132 static inline uintptr_t context_get_fp(context_t *ctx)
    133 {
    134         return 0;       /* FIXME */
    135 }
    136 
    137132#endif
    138133
  • uspace/lib/c/arch/mips32/include/fibril.h

    re503d3a9 rb14b71e  
    8585} context_t;
    8686
    87 static inline uintptr_t context_get_fp(context_t *ctx)
    88 {
    89         return ctx->sp;
    90 }
    91 
    9287#endif
    9388
  • uspace/lib/c/arch/ppc32/include/fibril.h

    re503d3a9 rb14b71e  
    7878} __attribute__ ((packed)) context_t;
    7979
    80 static inline uintptr_t context_get_fp(context_t *ctx)
    81 {
    82         return ctx->sp;
    83 }
    84 
    8580#endif
    8681
  • uspace/lib/c/arch/sparc64/include/fibril.h

    re503d3a9 rb14b71e  
    7777} context_t;
    7878
    79 static inline uintptr_t context_get_fp(context_t *ctx)
    80 {
    81         return ctx->sp + STACK_BIAS;
    82 }
    83 
    8479#endif
    8580
  • uspace/lib/c/generic/fibril.c

    re503d3a9 rb14b71e  
    275275        fibril->func = func;
    276276        fibril->arg = arg;
    277 
    278         fibril->waits_for = NULL;
    279277       
    280278        context_save(&fibril->ctx);
  • uspace/lib/c/generic/fibril_synch.c

    re503d3a9 rb14b71e  
    4242#include <errno.h>
    4343#include <assert.h>
    44 #include <stacktrace.h>
    45 #include <stdlib.h>
    4644
    4745static void optimize_execution_power(void)
     
    5856}
    5957
    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 
    9558void fibril_mutex_initialize(fibril_mutex_t *fm)
    9659{
    97         fm->oi.owned_by = NULL;
    9860        fm->counter = 1;
    9961        list_initialize(&fm->waiters);
     
    10264void fibril_mutex_lock(fibril_mutex_t *fm)
    10365{
    104         fibril_t *f = (fibril_t *) fibril_get_id();
    105 
    10666        futex_down(&async_futex);
    10767        if (fm->counter-- <= 0) {
     
    11373                link_initialize(&wdata.wu_event.link);
    11474                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 
    12075                fibril_switch(FIBRIL_TO_MANAGER);
    12176        } else {
    122                 fm->oi.owned_by = f;
    12377                futex_up(&async_futex);
    12478        }
     
    13286        if (fm->counter > 0) {
    13387                fm->counter--;
    134                 fm->oi.owned_by = (fibril_t *) fibril_get_id();
    13588                locked = true;
    13689        }
     
    14699                link_t *tmp;
    147100                awaiter_t *wdp;
    148                 fibril_t *f;
    149101       
    150102                assert(!list_empty(&fm->waiters));
     
    153105                wdp->active = true;
    154106                wdp->wu_event.inlist = false;
    155 
    156                 f = (fibril_t *) wdp->fid;
    157                 fm->oi.owned_by = f;
    158                 f->waits_for = NULL;
    159 
    160107                list_remove(&wdp->wu_event.link);
    161108                fibril_add_ready(wdp->fid);
    162109                optimize_execution_power();
    163         } else {
    164                 fm->oi.owned_by = NULL;
    165110        }
    166111}
     
    175120void fibril_rwlock_initialize(fibril_rwlock_t *frw)
    176121{
    177         frw->oi.owned_by = NULL;
    178122        frw->writers = 0;
    179123        frw->readers = 0;
  • uspace/lib/c/include/fibril.h

    re503d3a9 rb14b71e  
    4848#define FIBRIL_WRITER      2
    4949
    50 struct fibril;
    51 
    52 typedef struct {
    53         struct fibril *owned_by;
    54 } fibril_owner_info_t;
    55 
    5650typedef enum {
    5751        FIBRIL_PREEMPT,
     
    7468        int retval;
    7569        int flags;
    76 
    77         fibril_owner_info_t *waits_for;
    7870} fibril_t;
    7971
  • uspace/lib/c/include/fibril_synch.h

    re503d3a9 rb14b71e  
    4343
    4444typedef struct {
    45         fibril_owner_info_t oi;         /* Keep this the first thing. */
    4645        int counter;
    4746        link_t waiters;
     
    5049#define FIBRIL_MUTEX_INITIALIZER(name) \
    5150        { \
    52                 .oi = { \
    53                         .owned_by = NULL \
    54                 }, \
    5551                .counter = 1, \
    5652                .waiters = { \
     
    6460
    6561typedef struct {
    66         fibril_owner_info_t oi; /* Keep this the first thing. */
    6762        unsigned writers;
    6863        unsigned readers;
     
    7267#define FIBRIL_RWLOCK_INITIALIZER(name) \
    7368        { \
    74                 .oi = { \
    75                         .owned_by = NULL \
    76                 }, \
    7769                .readers = 0, \
    7870                .writers = 0, \
Note: See TracChangeset for help on using the changeset viewer.