|
|
用来控制挂起时间的。例如你主动调用delay或者阻塞于获取信号量等都会用到这个定时器。截取了一段信号量获取函数中的源码:% y: ~! a; Z) v* \9 t8 @
`
% F/ g5 r# A, M( q( ^; x/ start /
4 K* D# n) l4 z c/ Q- A! lrt_ipc_list_suspend(&(sem->parent.suspend_thread)," o% v' W2 U1 n
thread,
9 K" |* F. g, o) U3 R4 r% usem->parent.parent.flag);: c% m% L! s0 |3 I
5 e! C! h! W% _1 z2 E- P/* has waiting time, start thread timer */
2 t" u! k3 Z6 Vif (time > 0)' l* E. k% f4 _$ {+ F& l
{+ r( B1 r1 C, i4 r2 J& Q/ P
RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n",2 o/ c1 x v# L
thread->name));
' K# X7 f1 j; o7 c. ]9 O/* reset the timeout of thread timer and start it */. @9 i$ |8 i8 w/ v: y, w1 G( B( J
rt_timer_control(&(thread->thread_timer),
1 K# c* L" j1 ~ K% X) G9 k" j+ FRT_TIMER_CTRL_SET_TIME,) f% \6 m0 f$ v' O5 J
&time);
$ N1 @; d/ ]' x2 A7 ?4 d; hrt_timer_start(&(thread->thread_timer));
* K/ K2 ]$ k( ~}/ ?% M* s0 X/ v# S- R8 N
/* enable interrupt */
1 z& u% {8 `6 art_hw_interrupt_enable(temp);1 A% m0 k) ^, \* Z
/* do schedule */
! A; {5 X' R+ {+ ]' l% Grt_schedule(); rt_ipc_list_suspend(&(sem->parent.suspend_thread),- d( @* j1 h7 p8 P# ?- d2 l
thread,! K) ?) C8 S6 f: ]$ Z W' ~2 {
sem->parent.parent.flag);' [3 t. @* M2 i
/* has waiting time, start thread timer */
+ B) Q$ B7 M4 s2 F2 yif (time > 0)
) X7 {* t+ P; i4 i+ u+ h2 R, D{
! Y0 M: q+ Y5 S% S y) f# IRT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n",# M3 L7 T) c2 b% b' B
thread->name));
& N! T6 V7 B/ E0 r/* reset the timeout of thread timer and start it */
: y# @. N3 M& b( lrt_timer_control(&(thread->thread_timer),
' U. X6 B. G7 ?; VRT_TIMER_CTRL_SET_TIME,6 ?5 V: F( { y( K$ i; T
&time);
$ n& l1 \) D1 T4 m/ k& ~/ H' rrt_timer_start(&(thread->thread_timer));8 w# s) {+ i4 e. G
}& p3 w: f s$ N/ {( t y( u w
/* enable interrupt */
2 B' K7 h" e6 i, M1 Trt_hw_interrupt_enable(temp);! _* @$ u/ r4 K2 C3 f9 N' b
/* do schedule */+ {. O T5 p7 A; z/ C7 Q; o, U- P
rt_schedule();`
j( q1 j) B# c( ` |
|