Forum Discussion
Altera_Forum
Honored Contributor
21 years agoHi all,
hello wentao, thansk for answer, but.. the accuracy of the timer using SIGALRM signal is not enough, since when the period is small (I need 20ms periodic timing) then there is problem with high jiffy (jiffies), which is the basic time step for linux process management. It means, when any process is not handled by process mangement service now, then it is handled after one jiffy period when the next system timer interrupt occured. jiffy time is 10ms for stadard linux and it seems also for NIOS2 uClinux. I think so, because I tried small example, which initializes periodic timer with interrupt and just counted some value in interrupt routine and compared with realy real time on my watches and here are the results: period (watches time)/(NIOS2 "real" time) ------------------------------------------------------ 200ms 1.06 100ms 1.11 50ms 1.21 20ms 1.52 10ms 2.00 5ms 2.02 2ms 5.05 1ms 10.08 So as you can see, it looks very strange. My explanation comes from www.tldp.org, where they say, that after the kernel timer is served by appropriate process, it is always removed from timers queue by process manager.. and now it depends on, whether the periodic timer is restarted automatically - independantly on this machinery - which is the only case to produce exact periodic timing or the timer is renewed by process manager and due to this there is some additional processing delay (maybe even more complicated by the jiffy value, I suppose 10ms) which is added to the timer period.. So the SIGALRM use is definitelly not the right way for NIOS2 uClinux... From the kernel description I made my issue, that there is no chance to get exact timing only in kernel user space. There is also problem with modifying kernel, because I can not just write my own timer driver, due to the fact, that my process must be always handled by kernel process manager which works with default (big) jiffy step. The only way I see is the jiffy redesign to be much more smaller (< 1ms), but I am not experienced to do this.. I will be happy for any ideas http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif with regards Jan