Changeset 61ae4b0 in mainline


Ignore:
Timestamp:
2022-08-15T17:19:55Z (21 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ab855cd
Parents:
46b305a
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 17:04:19)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 17:19:55)
Message:

A bit of cleanup

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/cpu.h

    r46b305a r61ae4b0  
    7474        size_t missed_clock_ticks;
    7575
     76        /** Can only be accessed when interrupts are disabled. */
    7677        uint64_t current_clock_tick;
    7778
  • kernel/generic/src/time/timeout.c

    r46b305a r61ae4b0  
    8787        irq_spinlock_lock(&CPU->timeoutlock, true);
    8888
     89        assert(!link_in_use(&timeout->link));
     90
    8991        timeout->cpu = CPU;
    9092        timeout->deadline = CPU->current_clock_tick + us2ticks(time);
     
    9294        timeout->arg = arg;
    9395
    94         /*
    95          * Insert timeout into the active timeouts list according to timeout->deadline.
    96          */
    97         timeout_t *target = NULL;
    98         link_t *cur, *prev;
    99         prev = NULL;
    100         for (cur = list_first(&CPU->timeout_active_list);
    101             cur != NULL; cur = list_next(cur, &CPU->timeout_active_list)) {
    102                 target = list_get_instance(cur, timeout_t, link);
     96        /* Insert timeout into the active timeouts list according to timeout->deadline. */
    10397
    104                 if (timeout->deadline < target->deadline)
    105                         break;
     98        link_t *last = list_last(&CPU->timeout_active_list);
     99        if (last == NULL || timeout->deadline >= list_get_instance(last, timeout_t, link)->deadline) {
     100                list_append(&timeout->link, &CPU->timeout_active_list);
     101        } else {
     102                for (link_t *cur = list_first(&CPU->timeout_active_list); cur != NULL;
     103                    cur = list_next(cur, &CPU->timeout_active_list)) {
    106104
    107                 prev = cur;
     105                        if (timeout->deadline < list_get_instance(cur, timeout_t, link)->deadline) {
     106                                list_insert_before(&timeout->link, cur);
     107                                break;
     108                        }
     109                }
    108110        }
    109 
    110         if (prev == NULL)
    111                 list_prepend(&timeout->link, &CPU->timeout_active_list);
    112         else
    113                 list_insert_after(&timeout->link, prev);
    114111
    115112        irq_spinlock_unlock(&CPU->timeoutlock, true);
Note: See TracChangeset for help on using the changeset viewer.