summaryrefslogtreecommitdiff
path: root/include/linux/tqueue.h
blob: cca0b193617baf6cc8bc675ca334779ce7222f6f (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
/*
 * tqueue.h --- task queue handling for Linux.
 *
 * Modified version of previous incarnations of task-queues,
 * written by:
 *
 * (C) 1994 Kai Petzke, wpp@marie.physik.tu-berlin.de
 * Modified for use in the Linux kernel by Theodore Ts'o,
 * tytso@mit.edu.
 */

#ifndef _LINUX_TQUEUE_H
#define _LINUX_TQUEUE_H

#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/bitops.h>
#include <asm/system.h>

struct tq_struct {
	struct list_head list;		/* linked list of active tq's */
	unsigned long sync;		/* must be initialized to zero */
	void (*routine)(void *);	/* function to call */
	void *data;			/* argument to function */
};

/*
 * Emit code to initialise a tq_struct's routine and data pointers
 */
#define PREPARE_TQUEUE(_tq, _routine, _data)			\
	do {							\
		(_tq)->routine = _routine;			\
		(_tq)->data = _data;				\
	} while (0)

/*
 * Emit code to initialise all of a tq_struct
 */
#define INIT_TQUEUE(_tq, _routine, _data)			\
	do {							\
		INIT_LIST_HEAD(&(_tq)->list);			\
		(_tq)->sync = 0;				\
		PREPARE_TQUEUE((_tq), (_routine), (_data));	\
	} while (0)

#define DECLARE_TASK_QUEUE(q)	LIST_HEAD(q)

/* Schedule a tq to run in process context */
extern int schedule_task(struct tq_struct *task);

/* finish all currently pending tasks - do not call from irq context */
extern void flush_scheduled_tasks(void);

#endif