This source file includes following definitions.
- ps_set_intr
- ps_tq_int
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 #define PS_VERSION "1.02"
34
35 #include <linux/sched.h>
36 #include <linux/workqueue.h>
37
38 static void ps_tq_int(struct work_struct *work);
39
40 static void (* ps_continuation)(void);
41 static int (* ps_ready)(void);
42 static unsigned long ps_timeout;
43 static int ps_tq_active = 0;
44 static int ps_nice = 0;
45
46 static DEFINE_SPINLOCK(ps_spinlock __attribute__((unused)));
47
48 static DECLARE_DELAYED_WORK(ps_tq, ps_tq_int);
49
50 static void ps_set_intr(void (*continuation)(void),
51 int (*ready)(void),
52 int timeout, int nice)
53 {
54 unsigned long flags;
55
56 spin_lock_irqsave(&ps_spinlock,flags);
57
58 ps_continuation = continuation;
59 ps_ready = ready;
60 ps_timeout = jiffies + timeout;
61 ps_nice = nice;
62
63 if (!ps_tq_active) {
64 ps_tq_active = 1;
65 if (!ps_nice)
66 schedule_delayed_work(&ps_tq, 0);
67 else
68 schedule_delayed_work(&ps_tq, ps_nice-1);
69 }
70 spin_unlock_irqrestore(&ps_spinlock,flags);
71 }
72
73 static void ps_tq_int(struct work_struct *work)
74 {
75 void (*con)(void);
76 unsigned long flags;
77
78 spin_lock_irqsave(&ps_spinlock,flags);
79
80 con = ps_continuation;
81 ps_tq_active = 0;
82
83 if (!con) {
84 spin_unlock_irqrestore(&ps_spinlock,flags);
85 return;
86 }
87 if (!ps_ready || ps_ready() || time_after_eq(jiffies, ps_timeout)) {
88 ps_continuation = NULL;
89 spin_unlock_irqrestore(&ps_spinlock,flags);
90 con();
91 return;
92 }
93 ps_tq_active = 1;
94 if (!ps_nice)
95 schedule_delayed_work(&ps_tq, 0);
96 else
97 schedule_delayed_work(&ps_tq, ps_nice-1);
98 spin_unlock_irqrestore(&ps_spinlock,flags);
99 }
100
101
102