Subversion Repositories HelenOS-historic

Rev

Rev 1438 | Rev 1704 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1438 Rev 1457
Line 122... Line 122...
122
{
122
{
123
    link_t *l;
123
    link_t *l;
124
    timeout_t *h;
124
    timeout_t *h;
125
    timeout_handler_t f;
125
    timeout_handler_t f;
126
    void *arg;
126
    void *arg;
-
 
127
    count_t missed_clock_ticks = CPU->missed_clock_ticks;
127
    int i;
128
    int i;
128
 
129
 
129
    /*
130
    /*
130
     * To avoid lock ordering problems,
131
     * To avoid lock ordering problems,
131
     * run all expired timeouts as you visit them.
132
     * run all expired timeouts as you visit them.
132
     */
133
     */
133
    for (i = 0; i <= CPU->missed_clock_ticks; i++) {
134
    for (i = 0; i <= missed_clock_ticks; i++) {
134
        clock_update_counters();
135
        clock_update_counters();
135
        spinlock_lock(&CPU->timeoutlock);
136
        spinlock_lock(&CPU->timeoutlock);
136
        while ((l = CPU->timeout_active_head.next) != &CPU->timeout_active_head) {
137
        while ((l = CPU->timeout_active_head.next) != &CPU->timeout_active_head) {
137
            h = list_get_instance(l, timeout_t, link);
138
            h = list_get_instance(l, timeout_t, link);
138
            spinlock_lock(&h->lock);
139
            spinlock_lock(&h->lock);
Line 161... Line 162...
161
 
162
 
162
    if (THREAD) {
163
    if (THREAD) {
163
        __u64 ticks;
164
        __u64 ticks;
164
       
165
       
165
        spinlock_lock(&CPU->lock);
166
        spinlock_lock(&CPU->lock);
166
        CPU->needs_relink++;
167
        CPU->needs_relink += 1 + missed_clock_ticks;
167
        spinlock_unlock(&CPU->lock);   
168
        spinlock_unlock(&CPU->lock);   
168
   
169
   
169
        spinlock_lock(&THREAD->lock);
170
        spinlock_lock(&THREAD->lock);
170
        if ((ticks = THREAD->ticks))
171
        if ((ticks = THREAD->ticks)) {
-
 
172
            if (ticks >= 1 + missed_clock_ticks)
-
 
173
                THREAD->ticks -= 1 + missed_clock_ticks;
-
 
174
            else
171
            THREAD->ticks--;
175
                THREAD->ticks = 0;
-
 
176
        }
172
        spinlock_unlock(&THREAD->lock);
177
        spinlock_unlock(&THREAD->lock);
173
       
178
       
174
        if (!ticks && !PREEMPTION_DISABLED) {
179
        if (!ticks && !PREEMPTION_DISABLED) {
175
            scheduler();
180
            scheduler();
176
        }
181
        }