Subversion Repositories HelenOS-historic

Rev

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

Rev 103 Rev 107
Line 36... Line 36...
36
#include <cpu.h>
36
#include <cpu.h>
37
#include <print.h>
37
#include <print.h>
38
#include <arch/asm.h>
38
#include <arch/asm.h>
39
#include <arch.h>
39
#include <arch.h>
40
 
40
 
-
 
41
 
-
 
42
/** Initialize timeouts
-
 
43
 *
-
 
44
 * Initialize kernel timeouts.
-
 
45
 *
-
 
46
 */
41
void timeout_init(void)
47
void timeout_init(void)
42
{
48
{
43
    spinlock_initialize(&CPU->timeoutlock);
49
    spinlock_initialize(&CPU->timeoutlock);
44
    list_initialize(&CPU->timeout_active_head);
50
    list_initialize(&CPU->timeout_active_head);
45
}
51
}
46
 
52
 
47
 
53
 
-
 
54
/** Initialize empty timeout list
-
 
55
 *
-
 
56
 * Initialize the timeout list to be empty.
-
 
57
 *
-
 
58
 * @param t Timeout list to be initialized.
-
 
59
 *
-
 
60
 */
48
void timeout_reinitialize(timeout_t *t)
61
void timeout_reinitialize(timeout_t *t)
49
{
62
{
50
    t->cpu = NULL;
63
    t->cpu = NULL;
51
    t->ticks = 0;
64
    t->ticks = 0;
52
    t->handler = NULL;
65
    t->handler = NULL;
53
    t->arg = NULL;
66
    t->arg = NULL;
54
    link_initialize(&t->link);
67
    link_initialize(&t->link);
55
}
68
}
56
 
69
 
-
 
70
 
-
 
71
/** Initialize timeout list
-
 
72
 *
-
 
73
 * Initialize the timeout list and its spinlock.
-
 
74
 *
-
 
75
 * @param t Timeout list to be initialized.
-
 
76
 *
-
 
77
 */
57
void timeout_initialize(timeout_t *t)
78
void timeout_initialize(timeout_t *t)
58
{
79
{
59
    spinlock_initialize(&t->lock);
80
    spinlock_initialize(&t->lock);
60
    timeout_reinitialize(t);
81
    timeout_reinitialize(t);
61
}
82
}
62
 
83
 
-
 
84
 
-
 
85
/** Register timeout callback
63
/*
86
 *
-
 
87
 * Insert the timeout handler f (with argument arg)
-
 
88
 * to the timeout list and make it execute in
-
 
89
 * time microseconds (or slightly more).
-
 
90
 *
-
 
91
 * @param t    Timeout list.
64
 * This function registers f for execution in about time microseconds.
92
 * @patam time Number of usec in the future to execute
-
 
93
 *             the handler.
-
 
94
 * @param f    Timeout handler function.
-
 
95
 * @param arg  Timeout handler argument.
-
 
96
 *
65
 */
97
 */
66
void timeout_register(timeout_t *t, __u64 time, timeout_handler f, void *arg)
98
void timeout_register(timeout_t *t, __u64 time, timeout_handler f, void *arg)
67
{
99
{
68
    timeout_t *hlp;
100
    timeout_t *hlp;
69
    link_t *l, *m;
101
    link_t *l, *m;
Line 119... Line 151...
119
    spinlock_unlock(&t->lock);
151
    spinlock_unlock(&t->lock);
120
    spinlock_unlock(&CPU->timeoutlock);
152
    spinlock_unlock(&CPU->timeoutlock);
121
    cpu_priority_restore(pri);
153
    cpu_priority_restore(pri);
122
}
154
}
123
 
155
 
-
 
156
 
-
 
157
/** Unregister timeout callback
-
 
158
 *
-
 
159
 * Remove timeout from timeout list.
-
 
160
 *
-
 
161
 * @param t Timeout to unregister.
-
 
162
 *
-
 
163
 */
124
int timeout_unregister(timeout_t *t)
164
int timeout_unregister(timeout_t *t)
125
{
165
{
126
    timeout_t *hlp;
166
    timeout_t *hlp;
127
    link_t *l;
167
    link_t *l;
128
    pri_t pri;
168
    pri_t pri;