1,5 → 1,6 |
/* |
* Copyright (C) 2001-2004 Jakub Jermar |
* Copyright (C) 2007 Vojtech Mencl |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
55,7 → 56,11 |
#include <arch/barrier.h> |
#include <mm/frame.h> |
#include <ddi/ddi.h> |
|
#if defined CONFIG_TIMEOUT_AVL_TREE || defined CONFIG_TIMEOUT_EXTAVL_TREE |
#include <arch/asm.h> |
#include <arch/types.h> |
#include <panic.h> |
#endif |
/* Pointer to variable with uptime */ |
uptime_t *uptime; |
|
138,8 → 143,8 |
timeout_handler_t f; |
void *arg; |
count_t missed_clock_ticks = CPU->missed_clock_ticks; |
uint64_t *i = &(CPU->timeout_active_tree.base); |
uint64_t absolute_clock_ticks = *i + missed_clock_ticks; |
uint64_t i = CPU->timeout_active_tree.base; |
uint64_t last_clock_tick = i + missed_clock_ticks; |
avltree_node_t *expnode; |
|
/* |
147,15 → 152,11 |
* run all expired timeouts as you visit them. |
*/ |
|
for (; *i <= absolute_clock_ticks; (*i)++) { |
/* |
* Basetime is encreased by missed clock ticks + 1 !! |
*/ |
|
|
for (; i <= last_clock_tick; i++) { |
clock_update_counters(); |
spinlock_lock(&CPU->timeoutlock); |
|
|
/* |
* Check whether first timeout (with the smallest key in the tree) time out. If so perform |
* callback function and try next timeout (more timeouts can have same timeout). |
163,7 → 164,11 |
while ((expnode = avltree_find_min(&CPU->timeout_active_tree)) != NULL) { |
h = avltree_get_instance(expnode,timeout_t,node); |
spinlock_lock(&h->lock); |
if (expnode->key != *i) { |
if (expnode->key != i) { |
/* |
* Base is increased every for cycle. |
*/ |
(CPU->timeout_active_tree.base)++; |
spinlock_unlock(&h->lock); |
break; |
} |
229,9 → 234,10 |
timeout_handler_t f; |
void *arg; |
count_t missed_clock_ticks = CPU->missed_clock_ticks; |
uint64_t *i = &(CPU->timeout_active_tree.base); |
uint64_t absolute_clock_ticks = *i + missed_clock_ticks; |
uint64_t i = CPU->timeout_active_tree.base; |
uint64_t last_clock_tick = i + missed_clock_ticks; |
extavltree_node_t *expnode; |
//ipl_t ipl; |
|
/* |
* To avoid lock ordering problems, |
238,11 → 244,7 |
* run all expired timeouts as you visit them. |
*/ |
|
for (; *i <= absolute_clock_ticks; (*i)++) { |
/* |
* Basetime is encreased by missed clock ticks + 1 !! |
*/ |
|
for (; i <= last_clock_tick; i++) { |
clock_update_counters(); |
spinlock_lock(&CPU->timeoutlock); |
|
249,11 → 251,15 |
/* |
* Check whether first timeout in list time out. If so perform callback function and try |
* next timeout (more timeouts can have same timeout). |
*/ |
*/ |
while ((expnode = CPU->timeout_active_tree.head.next) != &(CPU->timeout_active_tree.head)) { |
h = extavltree_get_instance(expnode,timeout_t,node); |
spinlock_lock(&h->lock); |
if (expnode->key != *i) { |
spinlock_lock(&h->lock); |
if (expnode->key != i) { |
/* |
* Base is increased every for cycle. |
*/ |
(CPU->timeout_active_tree.base)++; |
spinlock_unlock(&h->lock); |
break; |
} |