blob: cc8db70bbc1c6882ba0c26b15b0755585444a904 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* scheduler.h - libtf fiber scheduler header
*
* Copyright (C) 2009-2010 Timo Teräs <timo.teras@iki.fi>
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 or later as
* published by the Free Software Foundation.
*
* See http://www.gnu.org/ for details.
*/
#ifndef TF_SCHEDULER_H
#define TF_SCHEDULER_H
#include <libtf/atomic.h>
#include <libtf/list.h>
#include <libtf/heap.h>
#include <libtf/fiber.h>
struct tf_scheduler {
struct tf_list_head scheduled_q;
struct tf_list_head running_q;
struct tf_heap_head heap;
void * active_fiber;
void * main_fiber;
int num_fibers;
tf_mtime_t scheduler_time;
unsigned long poll_data[2];
};
static inline
struct tf_scheduler *tf_scheduler_get_current(void)
{
extern struct tf_scheduler *__tf_scheduler;
TF_BUG_ON(__tf_scheduler == NULL);
return __tf_scheduler;
}
static inline
tf_mtime_t tf_scheduler_get_mtime(void)
{
return tf_scheduler_get_current()->scheduler_time;
}
struct tf_scheduler *tf_scheduler_create(void);
int tf_scheduler_enable(struct tf_scheduler *);
void tf_scheduler_disable(void);
static inline struct tf_scheduler *
tf_scheduler_get(struct tf_scheduler *s)
{
tf_fiber_get(s);
return s;
}
static inline void
tf_scheduler_put(struct tf_scheduler *s)
{
tf_fiber_put(s);
}
#endif
|