diff options
author | John M. Calandrino <jmc@jupiter-cs.cs.unc.edu> | 2007-03-29 15:18:56 -0400 |
---|---|---|
committer | John M. Calandrino <jmc@jupiter-cs.cs.unc.edu> | 2007-03-29 15:18:56 -0400 |
commit | 43795012bdc57fb329aeabfa33e2c67a8711f3c9 (patch) | |
tree | 5e33e0632559a2a89c381af5a87cfc98c413d47a /kernel | |
parent | 0a64e0838117c74b34f15493605669696ff8ccff (diff) |
Added necessary kernel support for zone-based locking.
Added two system calls, one to check if we are in the blocking zone, and
one to wait until we exit the blocking zone. Both calls rely on some
additional support from the local timer interrupt handler. Everything still
needs to be tested with the zone-lock implemention in user space,
especially under many different types of race conditions.
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/timer.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/kernel/timer.c b/kernel/timer.c index 532fdde9ba..3b12127c3c 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -737,29 +737,6 @@ static inline s64 __get_nsec_offset(void) | |||
737 | return ns_offset; | 737 | return ns_offset; |
738 | } | 738 | } |
739 | 739 | ||
740 | /* | ||
741 | * Public, non-inline version of the above function, used within | ||
742 | * local timer interrupt handler to get an idea of the current | ||
743 | * timestamp without locking. (We can't lock and are only reading, | ||
744 | * so it can only hurt us, not others.) | ||
745 | */ | ||
746 | s64 get_nsec_offset(void) | ||
747 | { | ||
748 | cycle_t cycle_now, cycle_delta; | ||
749 | s64 ns_offset; | ||
750 | |||
751 | /* read clocksource: */ | ||
752 | cycle_now = clocksource_read(clock); | ||
753 | |||
754 | /* calculate the delta since the last update_wall_time: */ | ||
755 | cycle_delta = (cycle_now - clock->cycle_last) & clock->mask; | ||
756 | |||
757 | /* convert to nanoseconds: */ | ||
758 | ns_offset = cyc2ns(clock, cycle_delta); | ||
759 | |||
760 | return ns_offset; | ||
761 | } | ||
762 | |||
763 | /** | 740 | /** |
764 | * __get_realtime_clock_ts - Returns the time of day in a timespec | 741 | * __get_realtime_clock_ts - Returns the time of day in a timespec |
765 | * @ts: pointer to the timespec to be set | 742 | * @ts: pointer to the timespec to be set |
@@ -812,6 +789,37 @@ void do_gettimeofday(struct timeval *tv) | |||
812 | } | 789 | } |
813 | 790 | ||
814 | EXPORT_SYMBOL(do_gettimeofday); | 791 | EXPORT_SYMBOL(do_gettimeofday); |
792 | |||
793 | /** | ||
794 | * do_getapproxtimeofday - Same as do_gettimeofday, but without any locking | ||
795 | * @tv: pointer of the timeval to be set | ||
796 | * | ||
797 | * Gets the approximate time of day, without claiming any locks, as it is to | ||
798 | * be used in the local timer interrupt handler. Since we only attempt to | ||
799 | * read the time here, this should not cause trouble for anything except the | ||
800 | * calling function. More testing is needed to determine if this is reasonably | ||
801 | * safe to do. | ||
802 | */ | ||
803 | void do_getapproxtimeofday(struct timeval *tv) | ||
804 | { | ||
805 | struct timespec now; | ||
806 | s64 nsecs; | ||
807 | |||
808 | /* Not using any synchronization that could cause problems | ||
809 | * inside the interrupt handler, we just try to read and | ||
810 | * suffer the consequences, if any. Note that nobody else | ||
811 | * will suffer consequences on our behalf, though. | ||
812 | */ | ||
813 | now = xtime; | ||
814 | nsecs = __get_nsec_offset(); | ||
815 | |||
816 | timespec_add_ns(&now, nsecs); | ||
817 | |||
818 | tv->tv_sec = now.tv_sec; | ||
819 | tv->tv_usec = now.tv_nsec/1000; | ||
820 | } | ||
821 | |||
822 | |||
815 | /** | 823 | /** |
816 | * do_settimeofday - Sets the time of day | 824 | * do_settimeofday - Sets the time of day |
817 | * @tv: pointer to the timespec variable containing the new time | 825 | * @tv: pointer to the timespec variable containing the new time |