Changeset 7064e71 in mainline


Ignore:
Timestamp:
2025-03-06T14:35:29Z (3 days ago)
Author:
Matěj Volf <git@…>
Children:
25ee7ec5
Parents:
9a41e6e
git-author:
Matěj Volf <git@…> (2025-03-05 23:09:43)
git-committer:
Matěj Volf <git@…> (2025-03-06 14:35:29)
Message:

run fibril exit hooks for main fibril as well

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/libc.c

    r9a41e6e r7064e71  
    8181                main_fibril.tcb = tls_make_initial(__progsymbols.elfstart);
    8282        }
     83        main_fibril.is_freeable = false;
    8384
    8485        assert(main_fibril.tcb);
     
    172173void __libc_exit(int status)
    173174{
    174         // TODO: some teardown of the main fibril?
    175         // namely, fibril_exit_hooks would like to run even on the main fibril
     175        fibril_run_exit_hooks(&main_fibril);
    176176
    177177        /*
  • uspace/lib/c/generic/private/fibril.h

    r9a41e6e r7064e71  
    9494extern void fibril_ipc_poke(void);
    9595
     96extern void fibril_run_exit_hooks(fibril_t *);
     97
    9698/**
    9799 * "Restricted" fibril mutex.
  • uspace/lib/c/generic/thread/fibril.c

    r9a41e6e r7064e71  
    199199        if (fibril->is_freeable) {
    200200                tls_free(fibril->tcb);
    201                 list_foreach_safe(fibril->exit_hooks, cur, _next) {
    202                         fibril_hook_t *hook = list_get_instance(cur, fibril_hook_t, link);
    203                         free(hook);
    204                 }
    205201                free(fibril);
    206202        }
     
    850846}
    851847
     848void fibril_run_exit_hooks(fibril_t *f)
     849{
     850        list_foreach_safe(f->exit_hooks, cur, _next) {
     851                fibril_hook_t *hook = list_get_instance(cur, fibril_hook_t, link);
     852                list_remove(cur);
     853                hook->func();
     854                free(hook);
     855        }
     856}
     857
    852858/**
    853859 * Exit a fibril. Never returns.
     
    860866        (void) retval;
    861867
    862         list_foreach(fibril_self()->exit_hooks, link, fibril_hook_t, hook) {
    863                 hook->func();
    864         }
     868        fibril_run_exit_hooks(fibril_self());
    865869
    866870        fibril_t *f = _ready_list_pop_nonblocking(false);
  • uspace/lib/posix/src/pthread/keys.c

    r9a41e6e r7064e71  
    104104{
    105105        /*
    106          * FIXME: this can cause a data race with another fibrill
    107          * running on_fibril_exit. The obvious solution is to add
    108          * a rwlock on the destructors array, which will be needed
    109          * anyway if we want to support unlimited number of keys.
     106         * FIXME: this can cause a data race if another fibrill concurrently
     107         * runs on_fibril_exit. The obvious solution is to add a rwlock on
     108         * the destructors array, which will be needed anyway if we want to
     109         * support unlimited number of keys.
    110110         */
    111111        destructors[key] = NULL;
  • uspace/srv/loader/main.c

    r9a41e6e r7064e71  
    355355        DPRINTF("Jump to entry point at %p\n", pcb.entry);
    356356
    357         // mvolfik is very confused: why is __libc_fini called BEFORE jumping to entrypoint??
    358357        __libc_fini();
    359358        __tcb_reset();
Note: See TracChangeset for help on using the changeset viewer.