Changeset 1871118 in mainline for kernel/generic/src/proc/task.c


Ignore:
Timestamp:
2023-02-10T22:59:11Z (19 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/proc/task.c

    rdaadfa6 r1871118  
    385385        irq_spinlock_lock(&tasks_lock, true);
    386386        irq_spinlock_lock(&TASK->lock, false);
    387         irq_spinlock_lock(&threads_lock, false);
    388387
    389388        /* Set task name */
    390389        str_cpy(TASK->name, TASK_NAME_BUFLEN, namebuf);
    391390
    392         irq_spinlock_unlock(&threads_lock, false);
    393391        irq_spinlock_unlock(&TASK->lock, false);
    394392        irq_spinlock_unlock(&tasks_lock, true);
     
    529527{
    530528        irq_spinlock_lock(&task->lock, false);
    531         irq_spinlock_lock(&threads_lock, false);
    532529
    533530        /*
     
    536533
    537534        list_foreach(task->threads, th_link, thread_t, thread) {
    538                 thread_interrupt(thread, false);
     535                thread_t *thr = thread_try_ref(thread);
     536                if (thr)
     537                        thread_interrupt(thr, false);
     538
     539                // If NULL, the thread is already getting destroyed concurrently with this.
    539540        }
    540541
    541         irq_spinlock_unlock(&threads_lock, false);
    542542        irq_spinlock_unlock(&task->lock, false);
    543543}
Note: See TracChangeset for help on using the changeset viewer.