Changeset 1871118 in mainline for kernel/generic/src/sysinfo/stats.c


Ignore:
Timestamp:
2023-02-10T22:59:11Z (21 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
11d2c983
Parents:
daadfa6
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-10 22:53:12)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-10 22:59:11)
Message:

Make thread_t reference counted

This simplifies interaction between various locks and thread
lifespan, which simplifies things. For example, threads_lock can
now simply be a mutex protecting the global it was made for, and
nothing more.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/sysinfo/stats.c

    rdaadfa6 r1871118  
    332332    bool dry_run, void *data)
    333333{
    334         /* Messing with threads structures, avoid deadlock */
     334        /* Messing with threads structures */
    335335        irq_spinlock_lock(&threads_lock, true);
    336336
     
    597597                return ret;
    598598
    599         /* Messing with threads structures, avoid deadlock */
     599        /* Messing with threads structures */
    600600        irq_spinlock_lock(&threads_lock, true);
    601601
     
    627627                ret.data.size = sizeof(stats_thread_t);
    628628
    629                 /* Hand-over-hand locking */
    630                 irq_spinlock_exchange(&threads_lock, &thread->lock);
    631 
     629                /*
     630                 * Replaced hand-over-hand locking with regular nested sections
     631                 * to avoid weak reference leak issues.
     632                 */
     633                irq_spinlock_lock(&thread->lock, false);
    632634                produce_stats_thread(thread, stats_thread);
    633 
    634                 irq_spinlock_unlock(&thread->lock, true);
     635                irq_spinlock_unlock(&thread->lock, false);
     636
     637                irq_spinlock_unlock(&threads_lock, true);
    635638        }
    636639
     
    847850void kload(void *arg)
    848851{
    849         thread_detach(THREAD);
    850 
    851852        while (true) {
    852853                size_t ready = atomic_load(&nrdy);
Note: See TracChangeset for help on using the changeset viewer.