Changeset ab855cd in mainline


Ignore:
Timestamp:
2022-08-15T17:20:56Z (21 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
eda43238
Parents:
61ae4b0
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 17:16:41)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 17:20:56)
Message:

Remove unnecessary loop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/time/clock.c

    r61ae4b0 rab855cd  
    138138{
    139139        size_t missed_clock_ticks = CPU->missed_clock_ticks;
     140        CPU->missed_clock_ticks = 0;
     141
    140142        CPU->current_clock_tick += missed_clock_ticks + 1;
    141143        uint64_t current_clock_tick = CPU->current_clock_tick;
     
    150152         *
    151153         */
    152         size_t i;
    153         for (i = 0; i <= missed_clock_ticks; i++) {
    154                 /* Update counters and accounting */
    155 
    156                 cpu_update_accounting();
     154
     155        irq_spinlock_lock(&CPU->timeoutlock, false);
     156
     157        link_t *cur;
     158        while ((cur = list_first(&CPU->timeout_active_list)) != NULL) {
     159                timeout_t *timeout = list_get_instance(cur, timeout_t, link);
     160
     161                if (current_clock_tick <= timeout->deadline) {
     162                        break;
     163                }
     164
     165                list_remove(cur);
     166                timeout_handler_t handler = timeout->handler;
     167                void *arg = timeout->arg;
     168
     169                irq_spinlock_unlock(&CPU->timeoutlock, false);
     170
     171                handler(arg);
    157172
    158173                irq_spinlock_lock(&CPU->timeoutlock, false);
    159 
    160                 link_t *cur;
    161                 while ((cur = list_first(&CPU->timeout_active_list)) != NULL) {
    162                         timeout_t *timeout = list_get_instance(cur, timeout_t,
    163                             link);
    164 
    165                         if (current_clock_tick <= timeout->deadline) {
    166                                 break;
    167                         }
    168 
    169                         list_remove(cur);
    170                         timeout_handler_t handler = timeout->handler;
    171                         void *arg = timeout->arg;
    172 
    173                         irq_spinlock_unlock(&CPU->timeoutlock, false);
    174 
    175                         handler(arg);
    176 
    177                         irq_spinlock_lock(&CPU->timeoutlock, false);
    178                 }
    179 
    180                 irq_spinlock_unlock(&CPU->timeoutlock, false);
    181174        }
    182         CPU->missed_clock_ticks = 0;
     175
     176        irq_spinlock_unlock(&CPU->timeoutlock, false);
    183177
    184178        /*
Note: See TracChangeset for help on using the changeset viewer.