Subversion Repositories HelenOS-historic

Rev

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

Rev 113 Rev 114
Line 115... Line 115...
115
         cpu_sleep();
115
         cpu_sleep();
116
         goto loop;
116
         goto loop;
117
    }
117
    }
118
 
118
 
119
    cpu_priority_high();
119
    cpu_priority_high();
120
 
120
   
-
 
121
    i = 0;
-
 
122
retry:
121
    for (i = 0; i<RQ_COUNT; i++) {
123
    for (; i<RQ_COUNT; i++) {
122
        r = &CPU->rq[i];
124
        r = &CPU->rq[i];
123
        spinlock_lock(&r->lock);
125
        spinlock_lock(&r->lock);
124
        if (r->n == 0) {
126
        if (r->n == 0) {
125
            /*
127
            /*
126
             * If this queue is empty, try a lower-priority queue.
128
             * If this queue is empty, try a lower-priority queue.
127
             */
129
             */
128
            spinlock_unlock(&r->lock);
130
            spinlock_unlock(&r->lock);
129
            continue;
131
            continue;
130
        }
132
        }
131
   
133
   
132
        atomic_dec(&nrdy);
134
        /* avoid deadlock with relink_rq */
-
 
135
        if (!spinlock_trylock(&CPU->lock)) {
133
 
136
            /*
-
 
137
             * Unlock r and try again.
-
 
138
             */
134
        spinlock_lock(&CPU->lock);
139
            spinlock_unlock(&r->lock);
-
 
140
            goto retry;
-
 
141
        }
135
        CPU->nrdy--;
142
        CPU->nrdy--;
136
        spinlock_unlock(&CPU->lock);
143
        spinlock_unlock(&CPU->lock);
137
 
144
 
-
 
145
        atomic_dec(&nrdy);
138
        r->n--;
146
        r->n--;
139
 
147
 
140
        /*
148
        /*
141
         * Take the first thread from the queue.
149
         * Take the first thread from the queue.
142
         */
150
         */