Subversion Repositories HelenOS

Rev

Rev 2450 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2450 Rev 2461
Line 56... Line 56...
56
{
56
{
57
    spinlock_initialize(&CPU->timeoutlock, "timeout_lock");
57
    spinlock_initialize(&CPU->timeoutlock, "timeout_lock");
58
 
58
 
59
#if defined CONFIG_TIMEOUT_AVL_TREE
59
#if defined CONFIG_TIMEOUT_AVL_TREE
60
    avltree_create(&CPU->timeout_active_tree);
60
    avltree_create(&CPU->timeout_active_tree);
-
 
61
#elif defined CONFIG_TIMEOUT_FAVL_TREE
-
 
62
    favltree_create(&CPU->timeout_active_tree);
61
#elif defined CONFIG_TIMEOUT_EXTAVL_TREE
63
#elif defined CONFIG_TIMEOUT_EXTAVL_TREE
62
    extavltree_create(&CPU->timeout_active_tree);
64
    extavltree_create(&CPU->timeout_active_tree);
63
#elif defined CONFIG_TIMEOUT_EXTAVLREL_TREE
65
#elif defined CONFIG_TIMEOUT_EXTAVLREL_TREE
64
    extavlreltree_create(&CPU->timeout_active_tree);
66
    extavlreltree_create(&CPU->timeout_active_tree);
65
#else
67
#else
Line 81... Line 83...
81
    t->handler = NULL;
83
    t->handler = NULL;
82
    t->arg = NULL;
84
    t->arg = NULL;
83
 
85
 
84
#if defined CONFIG_TIMEOUT_AVL_TREE
86
#if defined CONFIG_TIMEOUT_AVL_TREE
85
    avltree_node_initialize(&t->node);
87
    avltree_node_initialize(&t->node);
-
 
88
#elif defined CONFIG_TIMEOUT_FAVL_TREE
-
 
89
    favltree_node_initialize(&t->node);
86
#elif defined CONFIG_TIMEOUT_EXTAVL_TREE
90
#elif defined CONFIG_TIMEOUT_EXTAVL_TREE
87
    extavltree_node_initialize(&t->node);
91
    extavltree_node_initialize(&t->node);
88
#elif defined CONFIG_TIMEOUT_EXTAVLREL_TREE
92
#elif defined CONFIG_TIMEOUT_EXTAVLREL_TREE
89
    extavlreltree_node_initialize(&t->node);
93
    extavlreltree_node_initialize(&t->node);
90
#else
94
#else
Line 106... Line 110...
106
    spinlock_initialize(&t->lock, "timeout_t_lock");
110
    spinlock_initialize(&t->lock, "timeout_t_lock");
107
    timeout_reinitialize(t);
111
    timeout_reinitialize(t);
108
}
112
}
109
 
113
 
110
#if defined CONFIG_TIMEOUT_AVL_TREE || \
114
#if defined CONFIG_TIMEOUT_AVL_TREE || \
-
 
115
    defined CONFIG_TIMEOUT_FAVL_TREE || \
111
    defined CONFIG_TIMEOUT_EXTAVL_TREE || \
116
    defined CONFIG_TIMEOUT_EXTAVL_TREE || \
112
    defined CONFIG_TIMEOUT_EXTAVLREL_TREE
117
    defined CONFIG_TIMEOUT_EXTAVLREL_TREE
113
 
118
 
114
/** Register timeout
119
/** Register timeout
115
 *
120
 *
116
 * Insert timeout handler f (with argument arg)
121
 * Insert timeout handler f (with argument arg)
117
 * to timeout ExtAVL tree and make it execute in
122
 * to timeout tree and make it execute in
118
 * time microseconds (or slightly more).
123
 * time microseconds (or slightly more).
119
 *
124
 *
120
 * @param t    Timeout structure.
125
 * @param t    Timeout structure.
121
 * @param time Number of usec in the future to execute
126
 * @param time Number of usec in the future to execute
122
 *             the handler.
127
 *             the handler.
Line 139... Line 144...
139
    t->handler = f;
144
    t->handler = f;
140
    t->arg = arg;
145
    t->arg = arg;
141
    t->node.key = us2ticks(time);
146
    t->node.key = us2ticks(time);
142
 
147
 
143
    /*
148
    /*
144
     * Put timeout into tree structure.
149
     * Insert timeout into tree structure.
145
     */
150
     */
146
#if defined CONFIG_TIMEOUT_AVL_TREE
151
#if defined CONFIG_TIMEOUT_AVL_TREE
147
    avltree_insert(&CPU->timeout_active_tree,&t->node);
152
    avltree_insert(&CPU->timeout_active_tree,&t->node);
-
 
153
#elif defined CONFIG_TIMEOUT_FAVL_TREE
-
 
154
    favltree_insert(&CPU->timeout_active_tree,&t->node);
148
#elif defined CONFIG_TIMEOUT_EXTAVL_TREE
155
#elif defined CONFIG_TIMEOUT_EXTAVL_TREE
149
    extavltree_insert(&CPU->timeout_active_tree,&t->node);
156
    extavltree_insert(&CPU->timeout_active_tree,&t->node);
150
#elif defined CONFIG_TIMEOUT_EXTAVLREL_TREE
157
#elif defined CONFIG_TIMEOUT_EXTAVLREL_TREE
151
    extavlreltree_insert(&CPU->timeout_active_tree,&t->node);
158
    extavlreltree_insert(&CPU->timeout_active_tree,&t->node);
152
#endif
159
#endif
Line 157... Line 164...
157
}
164
}
158
 
165
 
159
 
166
 
160
/** Unregister timeout
167
/** Unregister timeout
161
 *
168
 *
162
 * Remove timeout from timeout ExtAVL tree structure.
169
 * Remove timeout from timeout tree structure.
163
 *
170
 *
164
 * @param t Timeout to unregister.
171
 * @param t Timeout to unregister.
165
 *
172
 *
166
 * @return true on success, false on failure.
173
 * @return true on success, false on failure.
167
 */
174
 */
Line 190... Line 197...
190
    /*
197
    /*
191
     * Delete timeout from tree structure.
198
     * Delete timeout from tree structure.
192
     */
199
     */
193
#if defined CONFIG_TIMEOUT_AVL_TREE
200
#if defined CONFIG_TIMEOUT_AVL_TREE
194
    avltree_delete(&t->cpu->timeout_active_tree,&t->node);
201
    avltree_delete(&t->cpu->timeout_active_tree,&t->node);
-
 
202
#elif defined CONFIG_TIMEOUT_FAVL_TREE
-
 
203
    favltree_delete(&t->cpu->timeout_active_tree,&t->node);
195
#elif defined CONFIG_TIMEOUT_EXTAVL_TREE
204
#elif defined CONFIG_TIMEOUT_EXTAVL_TREE
196
    extavltree_delete(&t->cpu->timeout_active_tree,&t->node);
205
    extavltree_delete(&t->cpu->timeout_active_tree,&t->node);
197
#elif defined CONFIG_TIMEOUT_EXTAVLREL_TREE
206
#elif defined CONFIG_TIMEOUT_EXTAVLREL_TREE
198
    extavlreltree_delete(&t->cpu->timeout_active_tree,&t->node);
207
    extavlreltree_delete(&t->cpu->timeout_active_tree,&t->node);
199
#endif
208
#endif