aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/posix-clock.h
diff options
context:
space:
mode:
authorRichard Cochran <richardcochran@gmail.com>2011-03-30 09:24:21 -0400
committerThomas Gleixner <tglx@linutronix.de>2011-04-18 04:39:38 -0400
commit1791f881435fab951939ad700e947b66c062e083 (patch)
tree53739cfe3847e425b9bb64f22bc7526da26a9a0c /include/linux/posix-clock.h
parenta1b49cb7e2a7961ec3aa8b64860bf480d4ec9077 (diff)
posix clocks: Replace mutex with reader/writer semaphore
A dynamic posix clock is protected from asynchronous removal by a mutex. However, using a mutex has the unwanted effect that a long running clock operation in one process will unnecessarily block other processes. For example, one process might call read() to get an external time stamp coming in at one pulse per second. A second process calling clock_gettime would have to wait for almost a whole second. This patch fixes the issue by using a reader/writer semaphore instead of a mutex. Signed-off-by: Richard Cochran <richard.cochran@omicron.at> Cc: John Stultz <john.stultz@linaro.org> Link: http://lkml.kernel.org/r/%3C20110330132421.GA31771%40riccoc20.at.omicron.at%3E Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux/posix-clock.h')
-rw-r--r--include/linux/posix-clock.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h
index 369e19d3750b..7f1183dcd119 100644
--- a/include/linux/posix-clock.h
+++ b/include/linux/posix-clock.h
@@ -24,6 +24,7 @@
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/poll.h> 25#include <linux/poll.h>
26#include <linux/posix-timers.h> 26#include <linux/posix-timers.h>
27#include <linux/rwsem.h>
27 28
28struct posix_clock; 29struct posix_clock;
29 30
@@ -104,7 +105,7 @@ struct posix_clock_operations {
104 * @ops: Functional interface to the clock 105 * @ops: Functional interface to the clock
105 * @cdev: Character device instance for this clock 106 * @cdev: Character device instance for this clock
106 * @kref: Reference count. 107 * @kref: Reference count.
107 * @mutex: Protects the 'zombie' field from concurrent access. 108 * @rwsem: Protects the 'zombie' field from concurrent access.
108 * @zombie: If 'zombie' is true, then the hardware has disappeared. 109 * @zombie: If 'zombie' is true, then the hardware has disappeared.
109 * @release: A function to free the structure when the reference count reaches 110 * @release: A function to free the structure when the reference count reaches
110 * zero. May be NULL if structure is statically allocated. 111 * zero. May be NULL if structure is statically allocated.
@@ -117,7 +118,7 @@ struct posix_clock {
117 struct posix_clock_operations ops; 118 struct posix_clock_operations ops;
118 struct cdev cdev; 119 struct cdev cdev;
119 struct kref kref; 120 struct kref kref;
120 struct mutex mutex; 121 struct rw_semaphore rwsem;
121 bool zombie; 122 bool zombie;
122 void (*release)(struct posix_clock *clk); 123 void (*release)(struct posix_clock *clk);
123}; 124};