Commit 00362e33 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Linus Torvalds

[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: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2bfb646c
...@@ -57,6 +57,19 @@ struct hrtimer { ...@@ -57,6 +57,19 @@ struct hrtimer {
struct hrtimer_base *base; struct hrtimer_base *base;
}; };
/**
* struct hrtimer_sleeper - simple sleeper structure
*
* @timer: embedded timer structure
* @task: task to wake up
*
* task is set to NULL, when the timer expires.
*/
struct hrtimer_sleeper {
struct hrtimer timer;
struct task_struct *task;
};
/** /**
* struct hrtimer_base - the timer base for a specific clock * struct hrtimer_base - the timer base for a specific clock
* *
...@@ -127,6 +140,9 @@ extern long hrtimer_nanosleep(struct timespec *rqtp, ...@@ -127,6 +140,9 @@ extern long hrtimer_nanosleep(struct timespec *rqtp,
const enum hrtimer_mode mode, const enum hrtimer_mode mode,
const clockid_t clockid); const clockid_t clockid);
extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
struct task_struct *tsk);
/* Soft interrupt function to run the hrtimer queues: */ /* Soft interrupt function to run the hrtimer queues: */
extern void hrtimer_run_queues(void); extern void hrtimer_run_queues(void);
......
...@@ -656,6 +656,25 @@ void hrtimer_run_queues(void) ...@@ -656,6 +656,25 @@ void hrtimer_run_queues(void)
* Sleep related functions: * Sleep related functions:
*/ */
static int hrtimer_wakeup(struct hrtimer *timer)
{
struct hrtimer_sleeper *t =
container_of(timer, struct hrtimer_sleeper, timer);
struct task_struct *task = t->task;
t->task = NULL;
if (task)
wake_up_process(task);
return HRTIMER_NORESTART;
}
void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, task_t *task)
{
sl->timer.function = hrtimer_wakeup;
sl->task = task;
}
struct sleep_hrtimer { struct sleep_hrtimer {
struct hrtimer timer; struct hrtimer timer;
struct task_struct *task; struct task_struct *task;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment