推 filiaslayers:之前做的時候,linux好像沒辦法做到這麼高的準度 07/18 09:53
→ scott260202:還是不行的話買個震晶自己弄上gpio? 不知道可不可以X 07/18 13:10
→ scott260202:D 07/18 13:11
→ user48625:不曉得若改成realtime OS有效嗎? 07/18 14:44
推 yvb:1. 是否已將 function/system call overhead 列入考慮 ? 07/18 15:01
我查到的clock_nanosleep的呼叫流程是:
clock_nanosleep() -->nsleep --> common_nsleep() -->hrtimer_nanosleep()
-->do_nanosleep()
資料:http://ppt.cc/wK3E
內文:do_nanosleep() will simply put the current task in INTERRUPTIBLE state, will
wait for the timer to expire(which is 1 ns) and then set the current task in
RUNNING state again. You see, there are lot of factors involved now, mainly
when your kernel thread (and hence the user space process) will be scheduled
again. Depending on your OS, you will always face some latency when your
doing a context-switch and this is what we observe with the average values.
若nanosleep的概念是用task的方式處理, 故我在想用realtime OS有沒有幫助..?
→ yvb:2. context switch 需要時間, 且可能有相當範圍的誤差. 07/18 15:03
這部份我不清楚switch的範圍誤差是多少, 但影響會到1us嗎?
→ yvb:3. 是否使用 chrt 之類調高執行的 priority ? 07/18 15:04
我用過renice但還沒試過chrt, 我renice bash 和 sudo 似乎沒有影響.
謝謝!
※ 編輯: user48625 (140.112.20.199), 07/18/2014 18:02:46
→ bitlife:需要us級精準度的,就不該使用OS了,應該是main loop程式自 07/19 12:58
→ bitlife:行控制會比較好.如果要用OS,可能要自己把sleep時間扣掉OS 07/19 12:59
→ bitlife:overhead,但這不保險,除非完全熟悉OS流程怎麼跑 07/19 13:00
→ user48625:謝謝,我查了一些資料,preempt的jitter似乎只能到10us.. 07/19 19:31
推 yvb:比起 Linux 板, 也許 LinuxDev 板更合適? 07/20 00:51
→ yvb:要求時間精度有幾種類型,包含讀取時間刻度,短延時,長延時幾種; 07/20 00:56
→ yvb:短延時比方10us delay不可誤差超過1us,長延時則如 1s 的誤差, 07/20 00:59
→ yvb:這幾種類型的處理方式都有相當的差異. 07/20 01:00
推 yvb:另外, b大的意思是完全不用OS? 或只是不要使用 syscall ? 07/20 01:04
推 gaiwei:schedule一定不準,但user mode好像沒busy waiting可用 07/23 00:49
→ gaiwei:考慮自己弄一個? 07/23 00:50