Subversion Repositories Kolibri OS

Rev

Rev 6082 | Rev 6125 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6082 Rev 6102
Line 5... Line 5...
5
#ifndef _LINUX_WORKQUEUE_H
5
#ifndef _LINUX_WORKQUEUE_H
6
#define _LINUX_WORKQUEUE_H
6
#define _LINUX_WORKQUEUE_H
Line 7... Line 7...
7
 
7
 
8
#include 
8
#include 
-
 
9
#include 
9
#include 
10
#include 
10
#include 
11
#include 
11
#include 
12
#include 
-
 
13
#include 
Line 12... Line -...
12
#include 
-
 
13
 
14
#include 
Line 14... Line 15...
14
#include 
15
 
15
struct workqueue_struct;
16
struct workqueue_struct;
16
 
17
 
Line 17... Line 18...
17
struct work_struct;
18
struct work_struct;
18
typedef void (*work_func_t)(struct work_struct *work);
19
typedef void (*work_func_t)(struct work_struct *work);
19
void __stdcall delayed_work_timer_fn(unsigned long __data);
20
void __stdcall delayed_work_timer_fn(unsigned long __data);
20
 
21
 
-
 
22
/*
-
 
23
 * The first word is the work queue pointer and the flags rolled into
21
/*
24
 * one
22
 * Workqueue flags and constants.  For details, please refer to
25
 */
23
 * Documentation/workqueue.txt.
26
#define work_data_bits(work) ((unsigned long *)(&(work)->data))
24
 */
27
 
25
enum {
28
enum {
26
    WQ_NON_REENTRANT    = 1 << 0, /* guarantee non-reentrance */
29
	WORK_STRUCT_PENDING_BIT	= 0,	/* work item is pending execution */
27
    WQ_UNBOUND          = 1 << 1, /* not bound to any cpu */
30
	WORK_STRUCT_DELAYED_BIT	= 1,	/* work item is delayed */
28
    WQ_FREEZABLE        = 1 << 2, /* freeze during suspend */
-
 
29
    WQ_MEM_RECLAIM      = 1 << 3, /* may be used for memory reclaim */
31
	WORK_STRUCT_PWQ_BIT	= 2,	/* data points to pwq */
30
    WQ_HIGHPRI          = 1 << 4, /* high priority */
-
 
31
    WQ_CPU_INTENSIVE    = 1 << 5, /* cpu instensive workqueue */
32
	WORK_STRUCT_LINKED_BIT	= 3,	/* next work is linked to this one */
32
 
-
 
33
    WQ_DRAINING         = 1 << 6, /* internal: workqueue is draining */
33
#ifdef CONFIG_DEBUG_OBJECTS_WORK
34
    WQ_RESCUER          = 1 << 7, /* internal: workqueue has rescuer */
-
 
35
 
34
	WORK_STRUCT_STATIC_BIT	= 4,	/* static initializer (debugobjects) */
Line -... Line 35...
-
 
35
	WORK_STRUCT_COLOR_SHIFT	= 5,	/* color for workqueue flushing */
Line -... Line 36...
-
 
36
#else
-
 
37
	WORK_STRUCT_COLOR_SHIFT	= 4,	/* color for workqueue flushing */
-
 
38
#endif
-
 
39
 
-
 
40
	WORK_STRUCT_COLOR_BITS	= 4,
-
 
41
 
-
 
42
	WORK_STRUCT_PENDING	= 1 << WORK_STRUCT_PENDING_BIT,
-
 
43
	WORK_STRUCT_DELAYED	= 1 << WORK_STRUCT_DELAYED_BIT,
-
 
44
	WORK_STRUCT_PWQ		= 1 << WORK_STRUCT_PWQ_BIT,
-
 
45
	WORK_STRUCT_LINKED	= 1 << WORK_STRUCT_LINKED_BIT,
-
 
46
#ifdef CONFIG_DEBUG_OBJECTS_WORK
-
 
47
	WORK_STRUCT_STATIC	= 1 << WORK_STRUCT_STATIC_BIT,
36
    WQ_MAX_ACTIVE       = 512,    /* I like 512, better ideas? */
48
#else
-
 
49
	WORK_STRUCT_STATIC	= 0,
-
 
50
#endif
-
 
51
 
-
 
52
	/*
-
 
53
	 * The last color is no color used for works which don't
-
 
54
	 * participate in workqueue flushing.
-
 
55
	 */
-
 
56
	WORK_NR_COLORS		= (1 << WORK_STRUCT_COLOR_BITS) - 1,
-
 
57
	WORK_NO_COLOR		= WORK_NR_COLORS,
-
 
58
 
37
    WQ_MAX_UNBOUND_PER_CPU  = 4,      /* 4 * #cpus for unbound wq */
59
	/* not bound to any CPU, prefer the local CPU */
-
 
60
	WORK_CPU_UNBOUND	= NR_CPUS,
-
 
61
 
-
 
62
	/*
-
 
63
	 * Reserve 7 bits off of pwq pointer w/ debugobjects turned off.
-
 
64
	 * This makes pwqs aligned to 256 bytes and allows 15 workqueue
-
 
65
	 * flush colors.
-
 
66
	 */
-
 
67
	WORK_STRUCT_FLAG_BITS	= WORK_STRUCT_COLOR_SHIFT +
-
 
68
				  WORK_STRUCT_COLOR_BITS,
-
 
69
 
-
 
70
	/* data contains off-queue information when !WORK_STRUCT_PWQ */
-
 
71
	WORK_OFFQ_FLAG_BASE	= WORK_STRUCT_COLOR_SHIFT,
-
 
72
 
38
    WQ_DFL_ACTIVE       = WQ_MAX_ACTIVE / 2,
73
	__WORK_OFFQ_CANCELING	= WORK_OFFQ_FLAG_BASE,
-
 
74
	WORK_OFFQ_CANCELING	= (1 << __WORK_OFFQ_CANCELING),
-
 
75
 
-
 
76
	/*
-
 
77
	 * When a work item is off queue, its high bits point to the last
-
 
78
	 * pool it was on.  Cap at 31 bits and use the highest number to
-
 
79
	 * indicate that no pool is associated.
-
 
80
	 */
-
 
81
	WORK_OFFQ_FLAG_BITS	= 1,
-
 
82
	WORK_OFFQ_POOL_SHIFT	= WORK_OFFQ_FLAG_BASE + WORK_OFFQ_FLAG_BITS,
-
 
83
	WORK_OFFQ_LEFT		= BITS_PER_LONG - WORK_OFFQ_POOL_SHIFT,
-
 
84
	WORK_OFFQ_POOL_BITS	= WORK_OFFQ_LEFT <= 31 ? WORK_OFFQ_LEFT : 31,
-
 
85
	WORK_OFFQ_POOL_NONE	= (1LU << WORK_OFFQ_POOL_BITS) - 1,
-
 
86
 
-
 
87
	/* convenience constants */
-
 
88
	WORK_STRUCT_FLAG_MASK	= (1UL << WORK_STRUCT_FLAG_BITS) - 1,
-
 
89
	WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK,
39
};
90
	WORK_STRUCT_NO_POOL	= (unsigned long)WORK_OFFQ_POOL_NONE << WORK_OFFQ_POOL_SHIFT,
-
 
91
 
40
 
92
	/* bit mask for work_busy() return values */
Line 41... Line 93...
41
 
93
	WORK_BUSY_PENDING	= 1 << 0,
42
struct workqueue_struct {
94
	WORK_BUSY_RUNNING	= 1 << 1,
43
    spinlock_t lock;
95
 
Line 52... Line 104...
52
#ifdef CONFIG_LOCKDEP
104
#ifdef CONFIG_LOCKDEP
53
	struct lockdep_map lockdep_map;
105
	struct lockdep_map lockdep_map;
54
#endif
106
#endif
55
};
107
};
Line -... Line 108...
-
 
108
 
-
 
109
#define WORK_DATA_INIT()	ATOMIC_LONG_INIT(WORK_STRUCT_NO_POOL)
-
 
110
#define WORK_DATA_STATIC_INIT()	\
-
 
111
	ATOMIC_LONG_INIT(WORK_STRUCT_NO_POOL | WORK_STRUCT_STATIC)
56
 
112
 
57
struct delayed_work {
113
struct delayed_work {
58
    struct work_struct work;
114
	struct work_struct work;
-
 
115
	unsigned int delay;
-
 
116
	/* target workqueue and CPU ->timer uses to queue ->work */
-
 
117
	struct workqueue_struct *wq;
59
    unsigned int delay;
118
	int cpu;
Line 60... Line 119...
60
};
119
};
61
 
120
 
62
static inline struct delayed_work *to_delayed_work(struct work_struct *work)
121
static inline struct delayed_work *to_delayed_work(struct work_struct *work)
63
{
122
{
Line -... Line 123...
-
 
123
	return container_of(work, struct delayed_work, work);
-
 
124
}
-
 
125
 
-
 
126
struct execute_work {
-
 
127
	struct work_struct work;
-
 
128
};
-
 
129
 
-
 
130
struct workqueue_struct {
-
 
131
    spinlock_t lock;
64
	return container_of(work, struct delayed_work, work);
132
    struct list_head worklist;
Line 65... Line 133...
65
}
133
    struct list_head delayed_worklist;
Line 66... Line 134...
66
 
134
};