Subversion Repositories HelenOS

Rev

Rev 2336 | Rev 2421 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2336 Rev 2416
1
/*
1
/*
2
 * Copyright (C) 2001-2004 Jakub Jermar
2
 * Copyright (C) 2001-2004 Jakub Jermar
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup time
29
/** @addtogroup time
30
 * @{
30
 * @{
31
 */
31
 */
32
 
32
 
33
/**
33
/**
34
 * @file
34
 * @file
35
 * @brief   High-level clock interrupt handler.
35
 * @brief   High-level clock interrupt handler.
36
 *
36
 *
37
 * This file contains the clock() function which is the source
37
 * This file contains the clock() function which is the source
38
 * of preemption. It is also responsible for executing expired
38
 * of preemption. It is also responsible for executing expired
39
 * timeouts.
39
 * timeouts.
40
 */
40
 */
41
 
41
 
42
#include <time/clock.h>
42
#include <time/clock.h>
43
#include <time/timeout.h>
43
#include <time/timeout.h>
44
#include <config.h>
44
#include <config.h>
45
#include <synch/spinlock.h>
45
#include <synch/spinlock.h>
46
#include <synch/waitq.h>
46
#include <synch/waitq.h>
47
#include <func.h>
47
#include <func.h>
48
#include <proc/scheduler.h>
48
#include <proc/scheduler.h>
49
#include <cpu.h>
49
#include <cpu.h>
50
#include <arch.h>
50
#include <arch.h>
51
#include <adt/list.h>
51
#include <adt/list.h>
52
#include <atomic.h>
52
#include <atomic.h>
53
#include <proc/thread.h>
53
#include <proc/thread.h>
54
#include <sysinfo/sysinfo.h>
54
#include <sysinfo/sysinfo.h>
55
#include <arch/barrier.h>
55
#include <arch/barrier.h>
56
#include <mm/frame.h>
56
#include <mm/frame.h>
57
#include <ddi/ddi.h>
57
#include <ddi/ddi.h>
58
 
58
 
59
/* Pointer to variable with uptime */
59
/* Pointer to variable with uptime */
60
uptime_t *uptime;
60
uptime_t *uptime;
61
 
61
 
62
/** Physical memory area of the real time clock */
62
/** Physical memory area of the real time clock */
63
static parea_t clock_parea;
63
static parea_t clock_parea;
64
 
64
 
65
/* Variable holding fragment of second, so that we would update
65
/* Variable holding fragment of second, so that we would update
66
 * seconds correctly
66
 * seconds correctly
67
 */
67
 */
68
static unative_t secfrag = 0;
68
static unative_t secfrag = 0;
69
 
69
 
70
/** Initialize realtime clock counter
70
/** Initialize realtime clock counter
71
 *
71
 *
72
 * The applications (and sometimes kernel) need to access accurate
72
 * The applications (and sometimes kernel) need to access accurate
73
 * information about realtime data. We allocate 1 page with these
73
 * information about realtime data. We allocate 1 page with these
74
 * data and update it periodically.
74
 * data and update it periodically.
75
 */
75
 */
76
void clock_counter_init(void)
76
void clock_counter_init(void)
77
{
77
{
78
    void *faddr;
78
    void *faddr;
79
 
79
 
80
    faddr = frame_alloc(ONE_FRAME, FRAME_ATOMIC);
80
    faddr = frame_alloc(ONE_FRAME, FRAME_ATOMIC);
81
    if (!faddr)
81
    if (!faddr)
82
        panic("Cannot allocate page for clock");
82
        panic("Cannot allocate page for clock");
83
   
83
   
84
    uptime = (uptime_t *) PA2KA(faddr);
84
    uptime = (uptime_t *) PA2KA(faddr);
85
   
85
   
86
    uptime->seconds1 = 0;
86
    uptime->seconds1 = 0;
87
    uptime->seconds2 = 0;
87
    uptime->seconds2 = 0;
88
    uptime->useconds = 0;
88
    uptime->useconds = 0;
89
 
89
 
90
    clock_parea.pbase = (uintptr_t) faddr;
90
    clock_parea.pbase = (uintptr_t) faddr;
91
    clock_parea.vbase = (uintptr_t) uptime;
91
    clock_parea.vbase = (uintptr_t) uptime;
92
    clock_parea.frames = 1;
92
    clock_parea.frames = 1;
93
    clock_parea.cacheable = true;
93
    clock_parea.cacheable = true;
94
    ddi_parea_register(&clock_parea);
94
    ddi_parea_register(&clock_parea);
95
 
95
 
96
    /*
96
    /*
97
     * Prepare information for the userspace so that it can successfully
97
     * Prepare information for the userspace so that it can successfully
98
     * physmem_map() the clock_parea.
98
     * physmem_map() the clock_parea.
99
     */
99
     */
100
    sysinfo_set_item_val("clock.cacheable", NULL, (unative_t) true);
100
    sysinfo_set_item_val("clock.cacheable", NULL, (unative_t) true);
101
    sysinfo_set_item_val("clock.faddr", NULL, (unative_t) faddr);
101
    sysinfo_set_item_val("clock.faddr", NULL, (unative_t) faddr);
102
}
102
}
103
 
103
 
104
 
104
 
105
/** Update public counters
105
/** Update public counters
106
 *
106
 *
107
 * Update it only on first processor
107
 * Update it only on first processor
108
 * TODO: Do we really need so many write barriers?
108
 * TODO: Do we really need so many write barriers?
109
 */
109
 */
110
static void clock_update_counters(void)
110
static void clock_update_counters(void)
111
{
111
{
112
    if (CPU->id == 0) {
112
    if (CPU->id == 0) {
113
        secfrag += 1000000 / HZ;
113
        secfrag += 1000000 / HZ;
114
        if (secfrag >= 1000000) {
114
        if (secfrag >= 1000000) {
115
            secfrag -= 1000000;
115
            secfrag -= 1000000;
116
            uptime->seconds1++;
116
            uptime->seconds1++;
117
            write_barrier();
117
            write_barrier();
118
            uptime->useconds = secfrag;
118
            uptime->useconds = secfrag;
119
            write_barrier();
119
            write_barrier();
120
            uptime->seconds2 = uptime->seconds1;
120
            uptime->seconds2 = uptime->seconds1;
121
        } else
121
        } else
122
            uptime->useconds += 1000000 / HZ;
122
            uptime->useconds += 1000000 / HZ;
123
    }
123
    }
124
}
124
}
125
 
125
 
-
 
126
#if defined CONFIG_TIMEOUT_AVL_TREE || \
126
#ifdef CONFIG_TIMEOUT_EXTAVL_TREE
127
    defined CONFIG_TIMEOUT_EXTAVL_TREE
127
 
128
 
128
/** Clock routine
129
/** Clock routine
129
 *
130
 *
130
 * Clock routine executed from clock interrupt handler
131
 * Clock routine executed from clock interrupt handler
131
 * (assuming interrupts_disable()'d). Runs expired timeouts
132
 * (assuming interrupts_disable()'d). Runs expired timeouts
132
 * and preemptive scheduling.
133
 * and preemptive scheduling.
133
 *
134
 *
134
 */
135
 */
135
void clock(void)
136
void clock(void)
136
{
137
{
137
    timeout_t *h;
138
    timeout_t *h;
138
    timeout_handler_t f;
139
    timeout_handler_t f;
139
    void *arg;
140
    void *arg;
140
    count_t missed_clock_ticks = CPU->missed_clock_ticks;
141
    count_t missed_clock_ticks = CPU->missed_clock_ticks;
141
    uint64_t *i = &(CPU->timeout_active_tree.basetime);
142
    uint64_t *i = &(CPU->timeout_active_tree.base);
142
    uint64_t absolute_clock_ticks = *i +
143
    uint64_t absolute_clock_ticks = *i + missed_clock_ticks;
-
 
144
#if defined CONFIG TIMEOUT_AVL_TREE
143
                                    missed_clock_ticks;
145
    avltree_node_t *expnode;
144
    extavltree_node_t *head = &(CPU->timeout_active_tree.head);
146
#elif defined CONFIG_TIMEOUT_EXTAVL_TREE
145
    extavltree_node_t *expnode = head->next;
147
    extavltree_node_t *expnode;
-
 
148
#endif
146
   
149
 
147
    /*
150
    /*
148
     * To avoid lock ordering problems,
151
     * To avoid lock ordering problems,
149
     * run all expired timeouts as you visit them.
152
     * run all expired timeouts as you visit them.
150
     */
153
     */
151
 
154
 
152
    for (; *i <= absolute_clock_ticks; (*i)++) {
155
    for (; *i <= absolute_clock_ticks; (*i)++) {
-
 
156
        /*
-
 
157
         * Basetime is encreased by missed clock ticks + 1 !!
-
 
158
         */
-
 
159
       
153
        clock_update_counters();
160
        clock_update_counters();
154
        spinlock_lock(&CPU->timeoutlock);
161
        spinlock_lock(&CPU->timeoutlock);
155
 
162
       
-
 
163
        /*
-
 
164
         * Check whether first timeout in list time out. If so perform callback function and try
-
 
165
         * next timeout (more timeouts can have same timeout).
-
 
166
         */
156
        while ((expnode = head->next) != head) {
167
        while ((expnode = CPU->timeout_active_tree.head.next) != &(CPU->timeout_active_tree.head)) {
157
            h = extavltree_get_instance(expnode,timeout_t,node);
168
            h = extavltree_get_instance(expnode,timeout_t,node);
158
            spinlock_lock(&h->lock);
169
            spinlock_lock(&h->lock);
159
            if (expnode->key != *i) {
170
            if (expnode->key != *i) {
160
                spinlock_unlock(&h->lock);
171
                spinlock_unlock(&h->lock);
161
                break;
172
                break;
162
            }
173
            }
163
           
174
           
-
 
175
            /*
-
 
176
             * Delete first node in the list and repair tree structure in
-
 
177
             * constant time.
-
 
178
             */
-
 
179
#if defined CONFIG TIMEOUT_AVL_TREE
-
 
180
            avltree_delete_min(&CPU->timeout_active_tree);
-
 
181
#elif defined CONFIG_TIMEOUT_EXTAVL_TREE
164
            extavltree_delete_min(&CPU->timeout_active_tree);
182
            extavltree_delete_min(&CPU->timeout_active_tree);
-
 
183
#endif
165
 
184
 
166
            f = h->handler;
185
            f = h->handler;
167
            arg = h->arg;
186
            arg = h->arg;
168
            timeout_reinitialize(h);
187
            timeout_reinitialize(h);
169
            spinlock_unlock(&h->lock); 
188
            spinlock_unlock(&h->lock); 
170
            spinlock_unlock(&CPU->timeoutlock);
189
            spinlock_unlock(&CPU->timeoutlock);
171
 
190
 
172
            f(arg);
191
            f(arg);
173
 
192
 
174
            spinlock_lock(&CPU->timeoutlock);
193
            spinlock_lock(&CPU->timeoutlock);
175
        }
194
        }
176
        spinlock_unlock(&CPU->timeoutlock);
195
        spinlock_unlock(&CPU->timeoutlock);
177
    }
196
    }
178
 
197
 
179
    CPU->missed_clock_ticks = 0;
198
    CPU->missed_clock_ticks = 0;
180
 
199
 
181
    /*
200
    /*
182
     * Do CPU usage accounting and find out whether to preempt THREAD.
201
     * Do CPU usage accounting and find out whether to preempt THREAD.
183
     */
202
     */
184
    if (THREAD) {
203
    if (THREAD) {
185
        uint64_t ticks;
204
        uint64_t ticks;
186
       
205
       
187
        spinlock_lock(&CPU->lock);
206
        spinlock_lock(&CPU->lock);
188
        CPU->needs_relink += 1 + missed_clock_ticks;
207
        CPU->needs_relink += 1 + missed_clock_ticks;
189
        spinlock_unlock(&CPU->lock);   
208
        spinlock_unlock(&CPU->lock);   
190
   
209
   
191
        spinlock_lock(&THREAD->lock);
210
        spinlock_lock(&THREAD->lock);
192
        if ((ticks = THREAD->ticks)) {
211
        if ((ticks = THREAD->ticks)) {
193
            if (ticks >= 1 + missed_clock_ticks)
212
            if (ticks >= 1 + missed_clock_ticks)
194
                THREAD->ticks -= 1 + missed_clock_ticks;
213
                THREAD->ticks -= 1 + missed_clock_ticks;
195
            else
214
            else
196
                THREAD->ticks = 0;
215
                THREAD->ticks = 0;
197
        }
216
        }
198
        spinlock_unlock(&THREAD->lock);
217
        spinlock_unlock(&THREAD->lock);
199
       
218
       
200
        if (!ticks && !PREEMPTION_DISABLED) {
219
        if (!ticks && !PREEMPTION_DISABLED) {
201
            scheduler();
220
            scheduler();
202
        }
221
        }
203
    }
222
    }
204
}
223
}
205
 
224
 
-
 
225
#elif defined CONFIG_TIMEOUT_EXTAVLREL_TREE
-
 
226
 
-
 
227
/** Clock routine
-
 
228
 *
-
 
229
 * Clock routine executed from clock interrupt handler
-
 
230
 * (assuming interrupts_disable()'d). Runs expired timeouts
-
 
231
 * and preemptive scheduling.
-
 
232
 *
-
 
233
 */
-
 
234
void clock(void)
-
 
235
{
-
 
236
    extavltree_node_t *expnode;
-
 
237
    timeout_t *h;
-
 
238
    timeout_handler_t f;
-
 
239
    void *arg;
-
 
240
    count_t missed_clock_ticks = CPU->missed_clock_ticks;
-
 
241
    int i;
-
 
242
 
-
 
243
    /*
-
 
244
     * To avoid lock ordering problems,
-
 
245
     * run all expired timeouts as you visit them.
-
 
246
     */
-
 
247
    for (i = 0; i <= missed_clock_ticks; i++) {
-
 
248
        clock_update_counters();
-
 
249
        spinlock_lock(&CPU->timeoutlock);
-
 
250
 
-
 
251
        /*
-
 
252
         * Check whether first timeout in list time out. If so perform callback function and try
-
 
253
         * next timeout (more timeouts can have same timeout).
-
 
254
         */
-
 
255
        while ((expnode = CPU->timeout_active_tree.head.next) != &(CPU->timeout_active_tree.head)) {
-
 
256
            h = list_get_instance(l, timeout_t, link);
-
 
257
            spinlock_lock(&h->lock);
-
 
258
            if (expnode->key != 0) {
-
 
259
                expnode->key--;
-
 
260
                spinlock_unlock(&h->lock);
-
 
261
                break;
-
 
262
            }
-
 
263
           
-
 
264
            /*
-
 
265
             * Delete first node in the list and repair tree structure in
-
 
266
             * constant time. Be careful of expnode's key, it must be 0!
-
 
267
             */
-
 
268
            extavltree_delete_min(&CPU->timeout_active_tree);
-
 
269
           
-
 
270
            f = h->handler;
-
 
271
            arg = h->arg;
-
 
272
            timeout_reinitialize(h);
-
 
273
            spinlock_unlock(&h->lock); 
-
 
274
            spinlock_unlock(&CPU->timeoutlock);
-
 
275
 
-
 
276
            f(arg);
-
 
277
 
-
 
278
            spinlock_lock(&CPU->timeoutlock);
-
 
279
        }
-
 
280
        spinlock_unlock(&CPU->timeoutlock);
-
 
281
    }
-
 
282
    CPU->missed_clock_ticks = 0;
-
 
283
 
-
 
284
    /*
-
 
285
     * Do CPU usage accounting and find out whether to preempt THREAD.
-
 
286
     */
-
 
287
 
-
 
288
    if (THREAD) {
-
 
289
        uint64_t ticks;
-
 
290
       
-
 
291
        spinlock_lock(&CPU->lock);
-
 
292
        CPU->needs_relink += 1 + missed_clock_ticks;
-
 
293
        spinlock_unlock(&CPU->lock);   
-
 
294
   
-
 
295
        spinlock_lock(&THREAD->lock);
-
 
296
        if ((ticks = THREAD->ticks)) {
-
 
297
            if (ticks >= 1 + missed_clock_ticks)
-
 
298
                THREAD->ticks -= 1 + missed_clock_ticks;
-
 
299
            else
-
 
300
                THREAD->ticks = 0;
-
 
301
        }
-
 
302
        spinlock_unlock(&THREAD->lock);
-
 
303
       
-
 
304
        if (!ticks && !PREEMPTION_DISABLED) {
-
 
305
            scheduler();
-
 
306
        }
-
 
307
    }
-
 
308
}
-
 
309
 
-
 
310
 
206
 
311
 
207
#else
312
#else
208
 
313
 
209
 
314
 
210
/** Clock routine
315
/** Clock routine
211
 *
316
 *
212
 * Clock routine executed from clock interrupt handler
317
 * Clock routine executed from clock interrupt handler
213
 * (assuming interrupts_disable()'d). Runs expired timeouts
318
 * (assuming interrupts_disable()'d). Runs expired timeouts
214
 * and preemptive scheduling.
319
 * and preemptive scheduling.
215
 *
320
 *
216
 */
321
 */
217
void clock(void)
322
void clock(void)
218
{
323
{
219
    link_t *l;
324
    link_t *l;
220
    timeout_t *h;
325
    timeout_t *h;
221
    timeout_handler_t f;
326
    timeout_handler_t f;
222
    void *arg;
327
    void *arg;
223
    count_t missed_clock_ticks = CPU->missed_clock_ticks;
328
    count_t missed_clock_ticks = CPU->missed_clock_ticks;
224
    int i;
329
    int i;
225
 
330
 
226
    /*
331
    /*
227
     * To avoid lock ordering problems,
332
     * To avoid lock ordering problems,
228
     * run all expired timeouts as you visit them.
333
     * run all expired timeouts as you visit them.
229
     */
334
     */
230
    for (i = 0; i <= missed_clock_ticks; i++) {
335
    for (i = 0; i <= missed_clock_ticks; i++) {
231
        clock_update_counters();
336
        clock_update_counters();
232
        spinlock_lock(&CPU->timeoutlock);
337
        spinlock_lock(&CPU->timeoutlock);
233
        while ((l = CPU->timeout_active_head.next) != &CPU->timeout_active_head) {
338
        while ((l = CPU->timeout_active_head.next) != &CPU->timeout_active_head) {
234
            h = list_get_instance(l, timeout_t, link);
339
            h = list_get_instance(l, timeout_t, link);
235
            spinlock_lock(&h->lock);
340
            spinlock_lock(&h->lock);
236
            if (h->ticks-- != 0) {
341
            if (h->ticks-- != 0) {
237
                spinlock_unlock(&h->lock);
342
                spinlock_unlock(&h->lock);
238
                break;
343
                break;
239
            }
344
            }
240
            list_remove(l);
345
            list_remove(l);
241
            f = h->handler;
346
            f = h->handler;
242
            arg = h->arg;
347
            arg = h->arg;
243
            timeout_reinitialize(h);
348
            timeout_reinitialize(h);
244
            spinlock_unlock(&h->lock); 
349
            spinlock_unlock(&h->lock); 
245
            spinlock_unlock(&CPU->timeoutlock);
350
            spinlock_unlock(&CPU->timeoutlock);
246
 
351
 
247
            f(arg);
352
            f(arg);
248
 
353
 
249
            spinlock_lock(&CPU->timeoutlock);
354
            spinlock_lock(&CPU->timeoutlock);
250
        }
355
        }
251
        spinlock_unlock(&CPU->timeoutlock);
356
        spinlock_unlock(&CPU->timeoutlock);
252
    }
357
    }
253
    CPU->missed_clock_ticks = 0;
358
    CPU->missed_clock_ticks = 0;
254
 
359
 
255
    /*
360
    /*
256
     * Do CPU usage accounting and find out whether to preempt THREAD.
361
     * Do CPU usage accounting and find out whether to preempt THREAD.
257
     */
362
     */
258
 
363
 
259
    if (THREAD) {
364
    if (THREAD) {
260
        uint64_t ticks;
365
        uint64_t ticks;
261
       
366
       
262
        spinlock_lock(&CPU->lock);
367
        spinlock_lock(&CPU->lock);
263
        CPU->needs_relink += 1 + missed_clock_ticks;
368
        CPU->needs_relink += 1 + missed_clock_ticks;
264
        spinlock_unlock(&CPU->lock);   
369
        spinlock_unlock(&CPU->lock);   
265
   
370
   
266
        spinlock_lock(&THREAD->lock);
371
        spinlock_lock(&THREAD->lock);
267
        if ((ticks = THREAD->ticks)) {
372
        if ((ticks = THREAD->ticks)) {
268
            if (ticks >= 1 + missed_clock_ticks)
373
            if (ticks >= 1 + missed_clock_ticks)
269
                THREAD->ticks -= 1 + missed_clock_ticks;
374
                THREAD->ticks -= 1 + missed_clock_ticks;
270
            else
375
            else
271
                THREAD->ticks = 0;
376
                THREAD->ticks = 0;
272
        }
377
        }
273
        spinlock_unlock(&THREAD->lock);
378
        spinlock_unlock(&THREAD->lock);
274
       
379
       
275
        if (!ticks && !PREEMPTION_DISABLED) {
380
        if (!ticks && !PREEMPTION_DISABLED) {
276
            scheduler();
381
            scheduler();
277
        }
382
        }
278
    }
383
    }
279
 
-
 
280
}
384
}
281
 
385
 
282
#endif
386
#endif
283
/** @}
387
/** @}
284
 */
388
 */
285
 
389