1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup rtems_bsd_rtems |
---|
5 | * |
---|
6 | * @brief TODO. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2012. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.com/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef RTEMS_TASKQUEUE_H |
---|
19 | #define RTEMS_TASKQUEUE_H |
---|
20 | |
---|
21 | #include <stdarg.h> |
---|
22 | |
---|
23 | #ifdef __cplusplus |
---|
24 | extern "C" { |
---|
25 | #endif |
---|
26 | |
---|
27 | struct taskqueue; |
---|
28 | |
---|
29 | typedef void (*task_fn)(void *ctxt, int pending); |
---|
30 | |
---|
31 | /* forwarded 'ctxt' that was passed to taskqueue_create() */ |
---|
32 | typedef void (*tq_enq_fn)(void *ctxt); |
---|
33 | |
---|
34 | struct task { |
---|
35 | struct task *ta_next; |
---|
36 | int ta_pending; |
---|
37 | int ta_priority; |
---|
38 | task_fn ta_fn; |
---|
39 | void *ta_fn_arg; |
---|
40 | }; |
---|
41 | |
---|
42 | struct taskqueue * |
---|
43 | taskqueue_create(const char *name, int mflags, tq_enq_fn, void *ctxt); |
---|
44 | |
---|
45 | struct taskqueue * |
---|
46 | taskqueue_create_fast(const char *name, int mflags, tq_enq_fn, void *ctxt); |
---|
47 | |
---|
48 | int |
---|
49 | taskqueue_enqueue(struct taskqueue *tq, struct task *ta); |
---|
50 | |
---|
51 | void |
---|
52 | taskqueue_thread_enqueue(void *ctxt); |
---|
53 | |
---|
54 | #define PI_NET 150 |
---|
55 | /* Returns 0 on success */ |
---|
56 | int |
---|
57 | taskqueue_start_threads(struct taskqueue **ptq, int count, int prio, const char *fmt, ...); |
---|
58 | |
---|
59 | void |
---|
60 | taskqueue_drain(struct taskqueue *tq, struct task *ta); |
---|
61 | |
---|
62 | void |
---|
63 | taskqueue_free(struct taskqueue *tq); |
---|
64 | |
---|
65 | #define TASK_INIT(task, pri, fn, arg) \ |
---|
66 | do { \ |
---|
67 | (task)->ta_next = 0; \ |
---|
68 | (task)->ta_priority = (pri); \ |
---|
69 | (task)->ta_pending = 0; \ |
---|
70 | (task)->ta_fn = (fn); \ |
---|
71 | (task)->ta_fn_arg = (arg); \ |
---|
72 | } while (0) |
---|
73 | |
---|
74 | extern struct taskqueue *taskqueue_fast; |
---|
75 | |
---|
76 | /* Initialize taskqueue facility [networking must have been initialized already] */ |
---|
77 | rtems_id |
---|
78 | rtems_taskqueue_initialize(); |
---|
79 | |
---|
80 | #ifdef __cplusplus |
---|
81 | } |
---|
82 | #endif |
---|
83 | |
---|
84 | #endif |
---|