Ignore:
File:
1 edited

Legend:

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

    r1b20da0 ra35b458  
    8484        if (faddr == 0)
    8585                panic("Cannot allocate page for clock.");
    86        
     86
    8787        uptime = (uptime_t *) PA2KA(faddr);
    88        
     88
    8989        uptime->seconds1 = 0;
    9090        uptime->seconds2 = 0;
    9191        uptime->useconds = 0;
    92        
     92
    9393        clock_parea.pbase = faddr;
    9494        clock_parea.frames = 1;
     
    9696        clock_parea.mapped = false;
    9797        ddi_parea_register(&clock_parea);
    98        
     98
    9999        /*
    100100         * Prepare information for the userspace so that it can successfully
     
    146146{
    147147        size_t missed_clock_ticks = CPU->missed_clock_ticks;
    148        
     148
    149149        /* Account CPU usage */
    150150        cpu_update_accounting();
    151        
     151
    152152        /*
    153153         * To avoid lock ordering problems,
     
    160160                clock_update_counters();
    161161                cpu_update_accounting();
    162                
     162
    163163                irq_spinlock_lock(&CPU->timeoutlock, false);
    164                
     164
    165165                link_t *cur;
    166166                while ((cur = list_first(&CPU->timeout_active_list)) != NULL) {
    167167                        timeout_t *timeout = list_get_instance(cur, timeout_t,
    168168                            link);
    169                        
     169
    170170                        irq_spinlock_lock(&timeout->lock, false);
    171171                        if (timeout->ticks-- != 0) {
     
    173173                                break;
    174174                        }
    175                        
     175
    176176                        list_remove(cur);
    177177                        timeout_handler_t handler = timeout->handler;
    178178                        void *arg = timeout->arg;
    179179                        timeout_reinitialize(timeout);
    180                        
     180
    181181                        irq_spinlock_unlock(&timeout->lock, false);
    182182                        irq_spinlock_unlock(&CPU->timeoutlock, false);
    183                        
     183
    184184                        handler(arg);
    185                        
     185
    186186                        irq_spinlock_lock(&CPU->timeoutlock, false);
    187187                }
    188                
     188
    189189                irq_spinlock_unlock(&CPU->timeoutlock, false);
    190190        }
    191191        CPU->missed_clock_ticks = 0;
    192        
     192
    193193        /*
    194194         * Do CPU usage accounting and find out whether to preempt THREAD.
    195195         *
    196196         */
    197        
     197
    198198        if (THREAD) {
    199199                uint64_t ticks;
    200                
     200
    201201                irq_spinlock_lock(&CPU->lock, false);
    202202                CPU->needs_relink += 1 + missed_clock_ticks;
    203203                irq_spinlock_unlock(&CPU->lock, false);
    204                
     204
    205205                irq_spinlock_lock(&THREAD->lock, false);
    206206                if ((ticks = THREAD->ticks)) {
     
    211211                }
    212212                irq_spinlock_unlock(&THREAD->lock, false);
    213                
     213
    214214                if (ticks == 0 && PREEMPTION_ENABLED) {
    215215                        scheduler();
Note: See TracChangeset for help on using the changeset viewer.