|
用来控制挂起时间的。例如你主动调用delay或者阻塞于获取信号量等都会用到这个定时器。截取了一段信号量获取函数中的源码:$ |9 n: H2 M1 V% ^1 X9 X
`$ y0 h$ U% s8 }4 ^5 L
/ start /, y, x; W$ S" M! F4 r7 X
rt_ipc_list_suspend(&(sem->parent.suspend_thread),
4 H% \+ e1 W* k0 rthread,& R% `; A$ e R( \6 o7 D
sem->parent.parent.flag);
+ W' [* c, y' [3 g" _( M" h
- y. `. c! B. o) k/ T$ x+ V/* has waiting time, start thread timer */0 K8 L, c! p( C9 o
if (time > 0)1 Z. N" X3 e" y$ p [
{+ e3 T6 Z* Y& Z% C
RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n",3 ^4 P, I# k0 H. {+ ~9 w7 _
thread->name));
9 N9 H/ R! j. Q9 S8 \/* reset the timeout of thread timer and start it */) s5 m/ ^# k2 u1 a
rt_timer_control(&(thread->thread_timer),1 { @; E4 h, [' W
RT_TIMER_CTRL_SET_TIME,6 C% {7 |* m" d7 _" X
&time);
% L! N4 b Y! |" U. \+ [* brt_timer_start(&(thread->thread_timer));/ |# ]7 M: V8 Z. E2 k* z, L
}7 F: [; k* k9 m' ~( X! I7 W! _
/* enable interrupt */" P% g/ M3 M/ \
rt_hw_interrupt_enable(temp);' E- m' I e: K# |1 F
/* do schedule */
/ R( X. O* F* @1 _/ }8 Rrt_schedule(); rt_ipc_list_suspend(&(sem->parent.suspend_thread),) h( E/ N% u! {/ h: ^4 T
thread," H/ {+ q+ [8 R6 [
sem->parent.parent.flag);
3 `; s8 G+ H" z0 {) v" L/* has waiting time, start thread timer */& Y, J5 v, ^0 G1 S, `7 }9 w- f B; \
if (time > 0)7 b# r8 H$ @2 q. [5 F# _
{! L l2 a0 c6 S- t, E
RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n",2 I, ~# h! r! A0 K! w3 ~
thread->name));* a+ [- ? e" d
/* reset the timeout of thread timer and start it */9 U" F' j( U: G- X0 X ~
rt_timer_control(&(thread->thread_timer),
8 ]3 T* d: O$ y4 m" R+ KRT_TIMER_CTRL_SET_TIME,8 H5 ]7 g6 r. e3 Q! w, i
&time);
$ {) y/ ^0 W2 E+ b! S' t. S F4 r! krt_timer_start(&(thread->thread_timer));
3 C4 t1 i; s) L4 K}$ U4 e$ R) M. a
/* enable interrupt */
4 j6 F5 \# i& o v* zrt_hw_interrupt_enable(temp);6 H4 L+ f, i, y8 Y0 s# |
/* do schedule */
3 R( P6 r* E" h1 c7 A- Xrt_schedule();`
: ^3 Y3 f- m" W* `: u |
|