Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/taskqueue.h
Show All 33 Lines | |||||
#endif | #endif | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/_task.h> | #include <sys/_task.h> | ||||
#include <sys/_callout.h> | #include <sys/_callout.h> | ||||
#include <sys/_cpuset.h> | #include <sys/_cpuset.h> | ||||
struct taskqueue; | struct taskqueue; | ||||
struct taskqgroup; | |||||
struct thread; | struct thread; | ||||
struct timeout_task { | struct timeout_task { | ||||
struct taskqueue *q; | struct taskqueue *q; | ||||
struct task t; | struct task t; | ||||
struct callout c; | struct callout c; | ||||
int f; | int f; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
static void \ | static void \ | ||||
taskqueue_define_##name(void *arg) \ | taskqueue_define_##name(void *arg) \ | ||||
{ \ | { \ | ||||
taskqueue_##name = \ | taskqueue_##name = \ | ||||
taskqueue_create(#name, M_WAITOK, (enqueue), (context)); \ | taskqueue_create(#name, M_WAITOK, (enqueue), (context)); \ | ||||
init; \ | init; \ | ||||
} \ | } \ | ||||
\ | \ | ||||
SYSINIT(taskqueue_##name, SI_SUB_CONFIGURE, SI_ORDER_SECOND, \ | SYSINIT(taskqueue_##name, SI_SUB_INIT_IF, SI_ORDER_SECOND, \ | ||||
taskqueue_define_##name, NULL); \ | taskqueue_define_##name, NULL); \ | ||||
\ | \ | ||||
struct __hack | struct __hack | ||||
#define TASKQUEUE_DEFINE_THREAD(name) \ | #define TASKQUEUE_DEFINE_THREAD(name) \ | ||||
TASKQUEUE_DEFINE(name, taskqueue_thread_enqueue, &taskqueue_##name, \ | TASKQUEUE_DEFINE(name, taskqueue_thread_enqueue, &taskqueue_##name, \ | ||||
taskqueue_start_threads(&taskqueue_##name, 1, PWAIT, \ | taskqueue_start_threads(&taskqueue_##name, 1, PWAIT, \ | ||||
"%s taskq", #name)) | "%s taskq", #name)) | ||||
/* | /* | ||||
* Define and initialise a global taskqueue that uses spin mutexes. | * Define and initialise a global taskqueue that uses spin mutexes. | ||||
*/ | */ | ||||
#define TASKQUEUE_FAST_DEFINE(name, enqueue, context, init) \ | #define TASKQUEUE_FAST_DEFINE(name, enqueue, context, init) \ | ||||
\ | \ | ||||
struct taskqueue *taskqueue_##name; \ | struct taskqueue *taskqueue_##name; \ | ||||
\ | \ | ||||
static void \ | static void \ | ||||
taskqueue_define_##name(void *arg) \ | taskqueue_define_##name(void *arg) \ | ||||
{ \ | { \ | ||||
taskqueue_##name = \ | taskqueue_##name = \ | ||||
taskqueue_create_fast(#name, M_WAITOK, (enqueue), \ | taskqueue_create_fast(#name, M_WAITOK, (enqueue), \ | ||||
(context)); \ | (context)); \ | ||||
init; \ | init; \ | ||||
} \ | } \ | ||||
\ | \ | ||||
SYSINIT(taskqueue_##name, SI_SUB_CONFIGURE, SI_ORDER_SECOND, \ | SYSINIT(taskqueue_##name, SI_SUB_INIT_IF, SI_ORDER_SECOND, \ | ||||
taskqueue_define_##name, NULL); \ | taskqueue_define_##name, NULL); \ | ||||
\ | \ | ||||
struct __hack | struct __hack | ||||
#define TASKQUEUE_FAST_DEFINE_THREAD(name) \ | #define TASKQUEUE_FAST_DEFINE_THREAD(name) \ | ||||
TASKQUEUE_FAST_DEFINE(name, taskqueue_thread_enqueue, \ | TASKQUEUE_FAST_DEFINE(name, taskqueue_thread_enqueue, \ | ||||
&taskqueue_##name, taskqueue_start_threads(&taskqueue_##name \ | &taskqueue_##name, taskqueue_start_threads(&taskqueue_##name \ | ||||
1, PWAIT, "%s taskq", #name)) | 1, PWAIT, "%s taskq", #name)) | ||||
Show All 17 Lines | |||||
* must be locked with spinlocks since sleep mutex's cannot be used | * must be locked with spinlocks since sleep mutex's cannot be used | ||||
* from a fast interrupt handler context. | * from a fast interrupt handler context. | ||||
*/ | */ | ||||
TASKQUEUE_DECLARE(fast); | TASKQUEUE_DECLARE(fast); | ||||
int taskqueue_enqueue_fast(struct taskqueue *queue, struct task *task); | int taskqueue_enqueue_fast(struct taskqueue *queue, struct task *task); | ||||
struct taskqueue *taskqueue_create_fast(const char *name, int mflags, | struct taskqueue *taskqueue_create_fast(const char *name, int mflags, | ||||
taskqueue_enqueue_fn enqueue, | taskqueue_enqueue_fn enqueue, | ||||
void *context); | void *context); | ||||
/* | |||||
* Taskqueue groups. Manages dynamic thread groups and irq binding for | |||||
* device and other tasks. | |||||
*/ | |||||
void taskqgroup_attach(struct taskqgroup *qgroup, struct grouptask *gtask, | |||||
void *uniq, int irq, char *name); | |||||
int taskqgroup_attach_cpu(struct taskqgroup *qgroup, struct grouptask *gtask, | |||||
void *uniq, int cpu, int irq, char *name); | |||||
void taskqgroup_detach(struct taskqgroup *qgroup, struct grouptask *gtask); | |||||
struct taskqgroup *taskqgroup_create(char *name); | |||||
void taskqgroup_destroy(struct taskqgroup *qgroup); | |||||
int taskqgroup_adjust(struct taskqgroup *qgroup, int cnt, int stride); | |||||
#define GROUPTASK_INIT(gtask, priority, func, context) \ | |||||
TASK_INIT(&(gtask)->gt_task, priority, func, context) | |||||
#define GROUPTASK_ENQUEUE(gtask) \ | |||||
taskqueue_enqueue((gtask)->gt_taskqueue, &(gtask)->gt_task) | |||||
#define TASKQGROUP_DECLARE(name) \ | |||||
extern struct taskqgroup *qgroup_##name | |||||
#define TASKQGROUP_DEFINE(name, cnt, stride) \ | |||||
\ | |||||
struct taskqgroup *qgroup_##name; \ | |||||
\ | |||||
static void \ | |||||
taskqgroup_define_##name(void *arg) \ | |||||
{ \ | |||||
qgroup_##name = taskqgroup_create(#name); \ | |||||
} \ | |||||
\ | |||||
SYSINIT(taskqgroup_##name, SI_SUB_CONFIGURE, SI_ORDER_SECOND, \ | |||||
taskqgroup_define_##name, NULL); \ | |||||
\ | |||||
static void \ | |||||
taskqgroup_adjust_##name(void *arg) \ | |||||
{ \ | |||||
taskqgroup_adjust(qgroup_##name, (cnt), (stride)); \ | |||||
} \ | |||||
\ | |||||
SYSINIT(taskqgroup_adj_##name, SI_SUB_SMP, SI_ORDER_ANY, \ | |||||
taskqgroup_adjust_##name, NULL); \ | |||||
\ | |||||
struct __hack | |||||
TASKQGROUP_DECLARE(net); | |||||
#endif /* !_SYS_TASKQUEUE_H_ */ | #endif /* !_SYS_TASKQUEUE_H_ */ |