|
|
用来控制挂起时间的。例如你主动调用delay或者阻塞于获取信号量等都会用到这个定时器。截取了一段信号量获取函数中的源码:' h9 ~3 b6 i4 G
`
# R& X* B/ c6 g5 t$ J8 i! D' ~/ start /
* G( z; V1 I! m$ e( Q# Art_ipc_list_suspend(&(sem->parent.suspend_thread),
) l. G9 a! M& B7 fthread,+ C# Y5 ?7 S; S
sem->parent.parent.flag);
# K/ {# Q4 d% b2 x, d9 D x& R; k/ D
/* has waiting time, start thread timer */* P: |7 }, A6 F# a
if (time > 0)# D4 k2 a( K. y
{
( O4 m1 Z, q- m/ |RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n",
5 ~; _) e! @6 gthread->name));2 H$ N' }1 {' i6 [1 e7 J7 @2 G# D
/* reset the timeout of thread timer and start it */; ?: [7 D3 q0 i, k M
rt_timer_control(&(thread->thread_timer),
+ ~( l( S6 ?% Q1 s! ^! a; \RT_TIMER_CTRL_SET_TIME,$ Z( V& n$ W. ~. ~% z+ v
&time);
; Y' w% i4 e T7 m j3 s& ~rt_timer_start(&(thread->thread_timer));
7 M. R/ \! R6 m# w}9 M# L. c% Y, h! H: H' ~, j2 ~
/* enable interrupt */
. v6 k* L+ ^/ a9 ?% Zrt_hw_interrupt_enable(temp);- R7 B8 r m' @0 g( h8 Q
/* do schedule */
8 W3 G3 Y+ w5 ^- s* Y' [rt_schedule(); rt_ipc_list_suspend(&(sem->parent.suspend_thread),
& z5 ~- q2 ~/ pthread,* L3 M$ b4 ?0 J$ q* S. U8 A
sem->parent.parent.flag);" G! X+ M/ M% M5 r- L9 a$ n
/* has waiting time, start thread timer */
7 J7 S8 S9 m$ a8 b q+ \4 Kif (time > 0)
( p+ o" ]3 M/ F{
% P! M" ]# _2 n. I" \ ?) z9 rRT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n",- r& A4 P( t4 S
thread->name));' h0 h5 T6 l E9 W. X: j ]
/* reset the timeout of thread timer and start it */
7 P: \% S* q/ R$ Z$ Urt_timer_control(&(thread->thread_timer),
3 m6 I5 j* K5 hRT_TIMER_CTRL_SET_TIME,. p# y! Z/ Q7 N
&time);
# ~; h9 I: I1 [- D7 W% |rt_timer_start(&(thread->thread_timer));1 A3 k6 c/ x; O
}
# {- Q. `' w& v+ t4 q1 d/ I( o/* enable interrupt */
; N. H7 E7 J8 w" j/ D8 X! N+ urt_hw_interrupt_enable(temp);
( D/ c) Z" h& o2 c4 [( D2 P/* do schedule */8 T Q+ Z3 {1 W4 q/ @* }
rt_schedule();`
& W5 g& K) i; X7 k( y7 p |
|