aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2006-03-31 05:31:17 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-31 15:18:58 -0500
commit00362e33f65f1cb5d15e62ea5509520ce2770360 (patch)
tree02694b1416f3d98c4eebaeca7864c7fd3bad6fa0
parent2bfb646cdf348cb77c572f06d5b9d17ea205c7e2 (diff)
[PATCH] hrtimer: create generic sleeper
The removal of the data field in the hrtimer structure enforces the embedding of the timer into another data structure. nanosleep now uses a private implementation of the most common used timer callback function (simple task wakeup). In order to avoid the reimplentation of such functionality all over the place a generic hrtimer_sleeper functionality is created. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/hrtimer.h16
-rw-r--r--kernel/hrtimer.c19
2 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 93830158348e..b20939287613 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -58,6 +58,19 @@ struct hrtimer {
58}; 58};
59 59
60/** 60/**
61 * struct hrtimer_sleeper - simple sleeper structure
62 *
63 * @timer: embedded timer structure
64 * @task: task to wake up
65 *
66 * task is set to NULL, when the timer expires.
67 */
68struct hrtimer_sleeper {
69 struct hrtimer timer;
70 struct task_struct *task;
71};
72
73/**
61 * struct hrtimer_base - the timer base for a specific clock 74 * struct hrtimer_base - the timer base for a specific clock
62 * 75 *
63 * @index: clock type index for per_cpu support when moving a timer 76 * @index: clock type index for per_cpu support when moving a timer
@@ -127,6 +140,9 @@ extern long hrtimer_nanosleep(struct timespec *rqtp,
127 const enum hrtimer_mode mode, 140 const enum hrtimer_mode mode,
128 const clockid_t clockid); 141 const clockid_t clockid);
129 142
143extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
144 struct task_struct *tsk);
145
130/* Soft interrupt function to run the hrtimer queues: */ 146/* Soft interrupt function to run the hrtimer queues: */
131extern void hrtimer_run_queues(void); 147extern void hrtimer_run_queues(void);
132 148
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 0237a556eb1f..877cdf9678bf 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -656,6 +656,25 @@ void hrtimer_run_queues(void)
656 * Sleep related functions: 656 * Sleep related functions:
657 */ 657 */
658 658
659static int hrtimer_wakeup(struct hrtimer *timer)
660{
661 struct hrtimer_sleeper *t =
662 container_of(timer, struct hrtimer_sleeper, timer);
663 struct task_struct *task = t->task;
664
665 t->task = NULL;
666 if (task)
667 wake_up_process(task);
668
669 return HRTIMER_NORESTART;
670}
671
672void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, task_t *task)
673{
674 sl->timer.function = hrtimer_wakeup;
675 sl->task = task;
676}
677
659struct sleep_hrtimer { 678struct sleep_hrtimer {
660 struct hrtimer timer; 679 struct hrtimer timer;
661 struct task_struct *task; 680 struct task_struct *task;