LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   shared timers between kernelspace and userspace (https://www.linuxquestions.org/questions/programming-9/shared-timers-between-kernelspace-and-userspace-738603/)

bizoo 07-08-2009 08:20 AM

shared timers between kernelspace and userspace
 
Hi,
I want to create a timer which i can use in both kernel and user space. I tried looking at different timer options such as timer_create or timerfd_create but according to my limited knowledge they look limited to one space (kernel/user) and not used in both. This way i will be able to do some measurements regarding duration of system calls etc

Any hints or pointers will be appreciated


cheers!

nanoo 07-09-2009 11:03 AM

Didnt get it. Processor can be only in one of the four states: user space, system call, soft interrupt, hard interrupt. As I understand the process timer event wake up some soft interrupt and your user space program will know about it only after soft intr and then syscall return. All other time it will be suspended.
Why don't you use gettimeofday(2) for measurements time in user space?

bizoo 07-09-2009 12:08 PM

hmm getimeofday or clock_getime serves the purpose too, but actually my goal is to synchronise two clocks (on two differenc PCs)and for that matter i dont want to change the system clock using set_clocktime as several processes rely on system clock.



So my idea was to make some timer of my own which receives a packet with sender timestamp, put its own timestamp in the kernel and the actual synchronization be done in user space. For that to happen, it should be one timer for kernel and user space.
i hope i have elaborated on my problem now

thanks in advance for suggestions!

nanoo 07-10-2009 03:33 AM

The solution strongly depend on precision of time measurement. What is matter for your task? milliseconds, mikro-, nano-?
For milli I would use this
http://www.linuxhomenetworking.com/w...The_NTP_Server
Set server on one computer and client on other one. Maybe this will work for mikro too.
Cannot suggest anything for nano.

bizoo 07-10-2009 05:34 AM

Yea i know about NTP,
but i am thinking of doing things on my own rather than using NTP or any other synch protocol
and then as the hrtimer in linux have nanosec resolution i can possibly achieve some higher accuracy.

thats my point and thats why i want a timer accessible in both kernel and userspace!


All times are GMT -5. The time now is 02:48 PM.