www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Thread fails to start

reply Adam Conner-Sax <adam_conner_sax yahoo.com> writes:
As a way to learn D, I am writing a quick test setup for examining different
ways of passing data from one set of threads to another.  I am trying a few
kinds of queues (resizeable array with locking, linked list with locking and
lockfree with cas) and trying to also add message passing and then compare
performance.

Anyway, I'm running into an odd case where a thread fails to start.  The code
simply hangs in the Threadgroup.create(...) call. I am printing (with
unbuffered i/o) right before the call to "create" and then as soon as the
threadfunction starts so as far as I can tell, the "create" call is made but
the threadfunc never starts and "create" never returns.

It's repeatable but doesn't happen every time the queue is used. It happens
sometimes when the queue is locking and sometimes when it is lockfree. I'd be
happy to post code but for now I thought I'd just see if anyone can think of
why that might happen or can provide some ideas for how to debug it.

The code always starts the one consumer thread (via spawn. I'm learning!),
then loops over the producers and creates them in a threadgroup just so I can
do a "joinAll" to wait for them to finish.  Also, when the problem occurs,
it's always the first producer thread that fails.  I never get 2 out of 4
started, e.g.


pleasure.

Any ideas would be appreciated.

Thanks!

Adam
Jan 01 2011
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 01/01/2011 06:02 PM, Adam Conner-Sax wrote:
 As a way to learn D, I am writing a quick test setup for examining different
 ways of passing data from one set of threads to another.  I am trying a few
 kinds of queues (resizeable array with locking, linked list with locking and
 lockfree with cas) and trying to also add message passing and then compare
 performance.

 Anyway, I'm running into an odd case where a thread fails to start.  The code
 simply hangs in the Threadgroup.create(...) call. I am printing (with
 unbuffered i/o) right before the call to "create" and then as soon as the
 threadfunction starts so as far as I can tell, the "create" call is made but
 the threadfunc never starts and "create" never returns.

 It's repeatable but doesn't happen every time the queue is used. It happens
 sometimes when the queue is locking and sometimes when it is lockfree. I'd be
 happy to post code but for now I thought I'd just see if anyone can think of
 why that might happen or can provide some ideas for how to debug it.

 The code always starts the one consumer thread (via spawn. I'm learning!),
 then loops over the producers and creates them in a threadgroup just so I can
 do a "joinAll" to wait for them to finish.  Also, when the problem occurs,
 it's always the first producer thread that fails.  I never get 2 out of 4
 started, e.g.


 pleasure.

 Any ideas would be appreciated.

 Thanks!

 Adam
Welcome. I suggest you post some code to serve as a basis for suggestions. Andrei
Jan 01 2011
parent reply Adam Conner-Sax <adam_conner_sax yahoo.com> writes:
== Quote from Andrei Alexandrescu (SeeWebsiteForEmail erdani.org)'s article
 On 01/01/2011 06:02 PM, Adam Conner-Sax wrote:
 As a way to learn D, I am writing a quick test setup for examining different
 ways of passing data from one set of threads to another.  I am trying a few
 kinds of queues (resizeable array with locking, linked list with locking and
 lockfree with cas) and trying to also add message passing and then compare
 performance.

 Anyway, I'm running into an odd case where a thread fails to start.  The code
 simply hangs in the Threadgroup.create(...) call. I am printing (with
 unbuffered i/o) right before the call to "create" and then as soon as the
 threadfunction starts so as far as I can tell, the "create" call is made but
 the threadfunc never starts and "create" never returns.

 It's repeatable but doesn't happen every time the queue is used. It happens
 sometimes when the queue is locking and sometimes when it is lockfree. I'd be
 happy to post code but for now I thought I'd just see if anyone can think of
 why that might happen or can provide some ideas for how to debug it.

 The code always starts the one consumer thread (via spawn. I'm learning!),
 then loops over the producers and creates them in a threadgroup just so I can
 do a "joinAll" to wait for them to finish.  Also, when the problem occurs,
 it's always the first producer thread that fails.  I never get 2 out of 4
 started, e.g.


 pleasure.

 Any ideas would be appreciated.

 Thanks!

 Adam
Welcome. I suggest you post some code to serve as a basis for suggestions. Andrei
Okay, thanks. Was trying to avoid subjecting you all to my naive first try code... alias void delegate(in Data_Packet d) sender; void produce(sender send, Random r, int packets, int packets_per_s, int us_variability) { debug { printf("in produce(...)\n"); } int packet_spacing = 10000000/packets_per_s; //units are 100ns // make sure we can't have -tve sleep int packet_variability = min(10*us_variability,packet_spacing+1); packets--; // one extra produced after loop with signal to end int counter = 0; while (counter++ < packets) { Data_Packet data; data.pTime = systime(); debug (5) { printf("Sending t=%i\n",data.pTime.value); } debug (3) { printf("S"); } send(data); Thread.sleep(packet_spacing + uniform(-packet_variability,packet_variability,r)); } Data_Packet data; data.last = true; data.pTime = systime(); send(data); } for (int k=0; k<num_producers_; ++k) { debug { printf("creating & starting producer\n"); } producer_threads[k] = producerThreads.create({produce(delegate void(in Data_Packet d) { q.produce(d); }, gen,packets_per_producer_,pps,microsecond_variability_);}); debug { printf("started.\n"); } } So, in the normal case, I get matched "creating & starting..." and "started" and "in produce()" In the case where it hangs, all I get is "Creating and starting..." and then it stays forever (or as long as I have patience to leave it). Full source attached begin 644 Queue.d M:6UP;W)T('-T9"YC+G-T9&EO.PT*:6UP;W)T(&-O<F4N871O;6EC.PT*:6UP M;W)T('-T9"YC;VYC=7)R96YC>3L-" T*+R\ 9FER<W0 =&%K92P =7-E9"!L M:6YK960 ;&ES=`T*+R\ ;6%Y8F4 9V5N97)A;&EZ92!M96UO<GD ;6]D96P- M('T-"B` ("!4('9A;'5E.PT*("` ($YO9&4 ;F5X=#L-"B` ?0T*("`-"B` M"B` ("!V;VED('!R;V1U8V4H:6X 5"!T*3L-"B` ("!B;V]L(&-O;G-U;64H M5&ED*%1I9"!T*3L-"B` ?0T*("`-"B` 8VQA<W, 1DE&3U],:6YK961,:7-T M3F]D92!F:7)S="P ;&%S=#L- M;VED(')E<V5T*"D >R!F:7)S="`](&QA<W0 /2!N97< 3F]D93L ?0T*("` M('1H:7,H*2![(')E<V5T*"D[('T-"B` ("`-"B` ("!S=')I;F< ;F%M92 I M('L <F5T=7)N(")&+$Q,+$QK(CL ?0T*("` ('-T<FEN9R!D97-C<FEP=&EO M;B I('L <F5T=7)N(")&249/.B!,;V-K:6YG+"!U<VEN9R!A(&QI;FME9"!L M:7-T(&%S('-T;W)A9V4N(CL ?0T*("` ("` (`T*("` ('9O:60 <')O9'5C M*3L-"B` ("` ('-Y;F-H<F]N:7IE9"`H=&AI<RD >PT*"71M<"YN97AT(#T M;&%S="YN97AT.PT*"6QA<W0N;F5X="`]('1M<#L M('T-"B` ("`-"B` ("!B;V]L(&-O;G-U;64H;W5T(%0 <F5S=6QT*2`-"B` M"2` <F5T=7)N(&9A;'-E.PT*"69I<G-T+FYE>'0 /2!T;7`N;F5X=#L-"B` M("` ('T-"B` ("` (')E<W5L="`]('1M<"YV86QU93L-"B` ("` (')E='5R M=%],;V-K:6YG7U%U975E(#H 475E=64-"B` >PT*("!P<FEV871E. T*("` M($YO9&4 ;&%S=#L- M<V5T*"D >R!L87-T(#T ;F5W($YO9&4[('T-"B` ("!T:&ES*"D >R!R97-E M3"Q,:R([('T-"B` ("!S=')I;F< 9&5S8W)I<'1I;VXH*2![(')E='5R;B`B M3$E&3SH 3&]C:VEN9RP =7-I;F< 82!L:6YK960 ;&ES="!A<R!S=&]R86=E M+B([('T-"B` ("` ("`-"B` ("!V;VED('!R;V1U8V4H:6X 5"!T*0T*("` M('L-"B` ("` ($YO9&4 =&UP(#T M:')O;FEZ960 *'1H:7,I('L-" ET;7`N;F5X="`](&QA<W0N;F5X=#L-" EL M.PT*"6QA<W0N;F5X="`]('1M<"YN97AT.PT*("` ("` ?0T*("` ("` <F5S M=6QT(#T M92!F:7)S="QL87-T.PT*("` ("` ("`-"B` <'5B;&EC. T*("` ('9O:60 M<F5S970H*2![(&9I<G-T(#T ;&%S="`](&YE=R!S:&%R960H3F]D92D[('T- M<V-R:7!T:6]N*"D >R!R971U<FX (D9)1D\Z($QO8VL 1G)E92`H=7-I;F< M8V%S*2P =7-I;F< 82!L:6YK960 ;&ES="!A<R!S=&]R86=E+B([('T-"B` M("`-"B` ("`-"B` ("!V;VED('!R;V1U8V4H:6X 5"!T*0T*("` ('L-"B` M("` ('-H87)E9"!A=71O('1M<"`](&YE=R!S:&%R960H3F]D92DH="D[("` M(`T*("` ("` 9&\ >PT*"71M<"YN97AT(#T ;&%S="YN97AT.PT*("` ("` M?2!W:&EL92`H(6-A<R F;&%S="YN97AT+'1M<"YN97AT+'1M<"DI.PT*("` M=&UP(#T 9FER<W0N;F5X=#L- M8VQA<W, 3$E&3U],:6YK961,:7-T7TQO8VM&<F5E7U%U975E(#H 475E=64- M("` ("` (`T*("` ('-T<FEN9R!N86UE*"D >R!R971U<FX (DPL3$PL3$8B M($QO8VL 1G)E92`H=7-I;F< 8V%S*2P =7-I;F< 82!L:6YK960 ;&ES="!A M<R!S=&]R86=E+B([('T-"B` ("`-"B` ("`-"B` ("!V;VED('!R;V1U8V4H M:6X 5"!T*0T*("` ('L-"B` ("` ('-H87)E9"!A=71O('1M<"`](&YE=R!S M:&%R960H3F]D92DH="D[("` (`T*("` ("` 9&\ >PT*"71M<"YN97AT(#T M;&%S="YN97AT.PT*("` ("` ?2!W:&EL92`H(6-A<R F;&%S="YN97AT+'1M M:7, ;G5L;"D-" D (')E='5R;B!F86QS93L-"B` ("` ('T =VAI;&4 *"%C M87,H)FQA<W0N;F5X="QT;7`L=&UP+FYE>'0I*3L-"B` ("` (`T*("` ("` M<F5S=6QT(#T =&UP+G9A;'5E.PT*("` ("` <F5T=7)N('1R=64[("` (`T* M7SL-"B` ("!46UT 8G5F9F5R7SL-"B` ("!I;G0 <W1A<G1I;F=?8G5F9F5R M7V1E<'1H7SL-"B` <'5B;&EC. T*("` ('-T<FEN9R!N86UE*"D >R!R971U M<FX (DPL0BQ,:R([('T-"B` ("!S=')I;F< 9&5S8W)I<'1I;VXH*2![(')E M='5R;B`B3$E&3SH 3&]C:VEN9RP =7-I;F< 82!D>6YA;6EC86QL>2!R97-I M=&%R=&EN9U]B=69F97)?9&5P=& ],3`P*0T*("` ("` >PT*"7-T87)T:6YG M970H*3L-"B` ("` ('T-"B` ("`-"B` ("!V;VED(')E<V5T*"D >PT*("` M("` 8G5F9F5R7R`](&YE=R!46W-T87)T:6YG7V)U9F9E<E]D97!T:%]=.PT* M("` ?G1H:7,H*0T*("` ("` >PT*"61E;&5T92!B=69F97)?.PT*("` ("` M("` ('-Y;F-H<F]N:7IE9"`H=&AI<RD >PT*"2HH8W5R<F5N=%\K*RD /2!T M=69F97)?6VPM,5T[("\O(')E<&]I;G0 870 96YD(`T*"2` <')I;G1F*")B M:&ES*2![("` ("`-" EI9B`H8W5R<F5N=%\ (3T )F)U9F9E<E];,%TI('L) M("`-" D ("` <F5S=6QT(#T *B M+6-U<G)E;G1?*3L-" D ("` <F5T=7)N M('T-" T*("!C;&%S<R!,249/7TUE<W-A9V5?4&%S<VEN9U]1=65U92`Z($UE M<W-A9V5?4&%S<VEN9U]1=65U92`-"B` >PT*("!P<FEV871E. T*("` (%1I M*2![(')E='5R;B`B3"Q-4"([('T-"B` ("!S=')I;F< 9&5S8W)I<'1I;VXH M=F]I9"!S971?8V]N<W5M97)?5&ED*%1I9"!T*2![(&-O;G-U;65R7W1I9%\ M;VYS=6UE<E]T:61?+'0I.PT*("` ('T-"B` ("`-"B` ("!B;V]L(&-O;G-U M"B` ("` ("\O<F5C96EV92 H5"!T*2![(')E<W5L="`]('0[('TI.PT*("` ` end begin 644 Queue_Test.d M:6UP;W)T('-T9"YC+G-T9&EO.PII;7!O<G0 8V]R92YT:')E860["FEM<&]R M="!S=&0N9&%T971I;64["FEM<&]R="!S=&0N<F%N9&]M.PII;7!O<G0 <W1D M+FUA=& ["FEM<&]R="!S=&0N86QG;W)I=&AM.PII;7!O<G0 <W1D+F9O<FUA M=#L*:6UP;W)T('-T9"YR86YG93L*:6UP;W)T('-T9"YC;VYC=7)R96YC>3L* M:6UP;W)T('-T9"YT<F%I=',[" II;7!O<G0 475E=64[" IT96UP;&%T92!1 M=65U95]497-T7U1Y<&5S*%0I(`I["B` <W1R=6-T($1A=&%?4&%C:V5T(`H M('L*("` (%1I8VMS('!4:6UE.PH ("` 8F]O;"!L87-T(#T 9F%L<V4["B` M("!4(&1U;6UY.PH ('T*"B` 86QI87, 475E=65?5'EP97,A*$1A=&%?4&%C M:V5T*2!15#L*"B` 86QI87, =F]I9"!D96QE9V%T92AI;B!$871A7U!A8VME M="!D*2!S96YD97(["B` 86QI87, 8F]O;"!D96QE9V%T92AO=70 1&%T85]0 M86-K970 9"D <F5C96EV97([" H ('9O:60 <')O9'5C92AS96YD97( <V5N M9"P 4F%N9&]M('(L(&EN="!P86-K971S+"!I;G0 <&%C:V5T<U]P97)?<RP M:6YT('5S7W9A<FEA8FEL:71Y*2`*("!["B` ("!D96)U9R![('!R:6YT9B B M:6X <')O9'5C92 N+BXI7&XB*3L ?0H ("` :6YT('!A8VME=%]S<&%C:6YG M(#T M"B` ("`O+R!M86ME('-U<F4 =V4 8V%N)W0 :&%V92`M='9E('-L965P"B` M("!I;G0 <&%C:V5T7W9A<FEA8FEL:71Y(#T M:71Y+'!A8VME=%]S<&%C:6YG*S$I.PH ("` "B` ("!P86-K971S+2T[("\O M(&]N92!E>'1R82!P<F]D=6-E9"!A9G1E<B!L;V]P('=I=& <VEG;F%L('1O M(&5N9`H ("` :6YT(&-O=6YT97( /2`P.PH ("` =VAI;&4 *&-O=6YT97(K M*R`\('!A8VME=',I("!["B` ("` ($1A=&%?4&%C:V5T(&1A=&$["B` ("` M(&1A=&$N<%1I;64 /2!S>7-T:6UE*"D["B` ("` (&1E8G5G(" U*2![('!R M:6YT9B B4V5N9&EN9R!T/25I7&XB+&1A=&$N<%1I;64N=F%L=64I.R!]"B` M("` (&1E8G5G(" S*2![('!R:6YT9B B4R(I.R!]"B` ("` ('-E;F0H9&%T M82D["B` ("` (%1H<F5A9"YS;&5E<"AP86-K971?<W!A8VEN9R`K('5N:69O M<FTH+7!A8VME=%]V87)I86)I;&ET>2QP86-K971?=F%R:6%B:6QI='DL<BDI M.PH ("` ?0H ("` 1&%T85]086-K970 9&%T83L*("` (&1A=&$N;&%S="`] M('1R=64["B` ("!D871A+G!4:6UE(#T <WES=&EM92 I.PH ("` <V5N9"AD M871A*3L*("!]"B` "B` "B` =F]I9"!C;VYS=6UE*&)O;VP 9&5L96=A=&4H M;W5T($1A=&%?4&%C:V5T(&0I(')E8V5I=F5?9BP :6YT(&YU;6)E<E]P86-K M971S+"!4:60 ;51I9"P ;W5T(&QO;F=;72!D96QA>7,I(`H ('L*("` (&1E M8G5G('L <')I;G1F*")I;B!C;VYS=6UE*"XN+BE<;B(I.R!]"B` ("!$871A M7U!A8VME="!D871A.PH ("` :6YT('!A8VME=%]N=6UB97(["B` ("!D96QA M>7,N;&5N9W1H(#T ;G5M8F5R7W!A8VME=',["B` ("!W:&EL92AP86-K971? M;G5M8F5R(#P ;G5M8F5R7W!A8VME=',I('L*("` ("` :68 *')E8V5I=F5? M9BAD871A*2D*"61E;&%Y<UMP86-K971?;G5M8F5R*RM=(#T <')O8V5S<U]P M86-K970H9&%T82D["B` ("!]"B` ("!D96)U9R![('!R:6YT9B B9FEN:7-H M960 8V]N<W5M92 N+BXI7&XB*3L ?0H ("` <')I;W)I='E396YD*"!M5&ED M("P =')U92D["B` ?0H*("!V;VED(&-O;G-U;65?;7`H:6YT(&YU;6)E<E]P M86-K971S+"!4:60 ;51I9"P ;W5T('-H87)E9"!L;VYG6UT 9&5L87ES*2`* M("!["B` ("`*("` (&1E8G5G('L <')I;G1F*")I;B!C;VYS=6UE7VUP*"XN M+BDB*3L ?0H ("` 1&%T85]086-K970 9&%T83L*("` (&EN="!P86-K971? M;G5M8F5R.PH ("` 9&5L87ES+FQE;F=T:"`](&YU;6)E<E]P86-K971S.PH M("` =VAI;&4H<&%C:V5T7VYU;6)E<B`\(&YU;6)E<E]P86-K971S*2`*("` M("` <F5C96EV92 H1&%T85]086-K970 9"D >R!D96QA>7-;<&%C:V5T7VYU M;6)E<BLK72`]('!R;V-E<W-?<&%C:V5T*&1A=&$I.R!]*3L*"B` ("!D96)U M9R![('!R:6YT9B B9FEN:7-H960 8V]N<W5M92 N+BXI7&XB*3L ?0H ("` M<')I;W)I='E396YD*"!M5&ED("P =')U92D["B` ?0H (`H*("!L;VYG('!R M;V-E<W-?<&%C:V5T*$1A=&%?4&%C:V5T(&1A=&$I(`H ('L*("` (&1E8G5G M(" U*2![('!R:6YT9B B4F5C)V0 =#TE:5QN(BQD871A+G!4:6UE+G9A;'5E M('!R:6YT9B B4F5C)V0 870 =#TE:5QN(BQC5&EM92YV86QU92D["B` ("!4 M:6-K<R!E;&%P<V5D(#T 8U1I;64 +2!D871A+G!4:6UE.PH ("` ;&]N9R!E M;&%P<V5D7W5S(#T 96QA<'-E9"YT;TUI8W)O<V5C;VYD<R$H;&]N9RDH*3L* M("` (&1E8G5G(" U*2!P<FEN=&8H(G5S/25I7&XB+&5L87!S961?=7,I.PH M("` <F5T=7)N(&5L87!S961?=7,["B` ?0H*("`*("!C;&%S<R!1=65U95]4 M97-T('L*("` (&EM;75T86)L92!S=')I;F< 5&5S=%]);F9O7TAE861E<B`] M(")0<F]D<UQT<&MT<UQ<<')O9%QT<&MT<UQ<<UQT:FET=&5R(CL*("` (&EM M;75T86)L92!S=')I;F< 4G5N7TEN9F]?2&5A9&5R(#T (E%U975E7'0 5&]T M('-<="!A=F=<="` <V1<=&UI;EQT(&UA>%QT/&UI;CY<="`\;6%X/EQN7U]? M7U]?7'1?7U]?7U]<=%]?7U]?7'1?7U]?7UQT7U]?7'1?7U]?7UQT7U]?7U]< M=%]?7U]?7U\B.PH*("!P<FEV871E. H ("` "B` ("`O+R!F;W( =&5S="!I M;G!U=',*("` (&EN="!N=6U?<')O9'5C97)S7RP <&%C:V5T<U]P97)?<')O M9'5C97)?+"!A=F=?<&%C:V5T<U]P97)?<U\L(&UI8W)O<V5C;VYD7W9A<FEA M8FEL:71Y7SL*("` (`H ("` +R\ 9F]R('1E<W0 ;W5T<'5T<PH ("` ;&]N M9R!M87AI;75M7RQM:6YI;75M7RQ.7SL*("` (&1O=6)L92!A=F=?+"!S=&1? M9&5V7RP 879G7VUI;E\L(&%V9U]M87A?+"!R=6Y?<U\["B` ("!S=')I;F< M<5]N86UE7SL*("` (`H ('!U8FQI8SH*("` ('1H:7,H:6YT(&YU;5]P<F]D M=6-E<G,L(&EN="!P86-K971S7W!E<E]P<F]D=6-E<BP :6YT(&%V9U]P86-K M971S7W!E<E]S+"!I;G0 ;6EC<F]S96-O;F1?=F%R:6%B:6QI='DI(`H ("` M>PH ("` ("!N=6U?<')O9'5C97)S7R`](&YU;5]P<F]D=6-E<G,["B` ("` M('!A8VME='-?<&5R7W!R;V1U8V5R7R`]('!A8VME='-?<&5R7W!R;V1U8V5R M.PH ("` ("!A=F=?<&%C:V5T<U]P97)?<U\ /2!A=F=?<&%C:V5T<U]P97)? M<SL*("` ("` ;6EC<F]S96-O;F1?=F%R:6%B:6QI='E?(#T ;6EC<F]S96-O M;F1?=F%R:6%B:6QI='D["B` ("!]"B` ("`*("` ('-T<FEN9R!497-T7TEN M9F\H*2![(`H ("` ("!A=71O('=R:71E<B`](&%P<&5N9&5R(7-T<FEN9R I M.PD ("` "B` ("` (&9O<FUA='1E9%=R:71E*'=R:71E<BPB)7, <')O9'5C M97(H<RD 96%C:"!P<F]D=6-I;F< )7, <&%C:V5T<R!A="`E<R!P:W1S+W, M*'1O=&%L*2!W:71H("5S('5S(&II='1E<CHB+&YU;5]P<F]D=6-E<G-?+'!A M8VME='-?<&5R7W!R;V1U8V5R7RQA=F=?<&%C:V5T<U]P97)?<U\L;6EC<F]S M96-O;F1?=F%R:6%B:6QI='E?*3L*("` ("` <F5T=7)N('=R:71E<BYD871A M.PH ("` ?0H ("` "B` ("`*("` ('-T<FEN9R!2=6Y?26YF;R I('L*("` M("` 875T;R!W<FET97( /2!A<'!E;F1E<B%S=')I;F<H*3L*("` ("` 9F]R M;6%T=&5D5W)I=&4H=W)I=&5R+"(E<UQT)38N,F9<="4U+C)F7'0E-2XR9EQT M)3)S(BQQ7VYA;65?+')U;E]S7RQA=F=?+'-T9%]D979?+&UI;FEM=6U?*3L* M("` ("` 9F]R;6%T=&5D5W)I=&4H=W)I=&5R+")<="4U<R(L(&UA>&EM=6U? M*3L*("` ("` 9F]R;6%T=&5D5W)I=&4H=W)I=&5R+")<="4U+C)F(BQA=F=? M;6EN7RD["B` ("` (&9O<FUA='1E9%=R:71E*'=R:71E<BPB7'0E-RXR9B(L M879G7VUA>%\I.PH ("` ("!R971U<FX =W)I=&5R+F1A=&$["B` ("!]"B` M("`*("` (&)O;VP :7-?;7!?<75E=64H5"DH5"!Q*2!["B` ("` (')E='5R M;B!H87--96UB97(A*%0L(G-E=%]C;VYS=6UE<E]4:60B*3L*("` ('T*"B` M("!V;VED(')U;BA15"Y1=65U92!Q*0H ("` >PH ("` ("!Q7VYA;65?(#T M<2YN86UE.PH ("` ("!Q+G)E<V5T*"D["B` ("` ("\O(&-R96%T92!A('!R M;V1U8V5R('1H<F5A9"!A;F0 82!C;VYS=6UE<B!T:')E860*("` ("` 4F%N M9&]M(&=E;CL*("` ("` :6YT(&YU;5]P86-K971S(#T ;G5M7W!R;V1U8V5R M<U\J<&%C:V5T<U]P97)?<')O9'5C97)?.PH ("` (`H ("` ("`O+VQO;F=; M72!D96QA>7,["B` ("` (&)O;VP 8V]N<W5M97)?9FEN:7-H960 /2!F86QS M93L*("` ("` "B` ("` (%1I9"!T(#T =&AI<U1I9" I.PH ("` ("!4:60 M8V]N<W5M97)?=&ED.PH ("` ("!L;VYG6UT 9&5L87ES.PH ("` ("!S:&%R M960 ;&]N9UM=('-D96QA>7,["B` ("` (%1H<F5A9"!C;VYS=6UE<CL*"B` M("` (&EF("AI<U]M<%]Q=65U92AQ*2D >PH)8V]N<W5M97)?=&ED(#T <W!A M=VXH)F-O;G-U;65?;7`L;G5M7W!A8VME=',L="QS9&5L87ES*3L*"2AC87-T M*%%4+DUE<W-A9V5?4&%S<VEN9U]1=65U92EQ*2YS971?8V]N<W5M97)?5&ED M*&-O;G-U;65R7W1I9"D["B` ("` ('T*("` ("` 96QS92![" EC;VYS=6UE M<B`](&YE=R!4:')E860H>R!C;VYS=6UE*&1E;&5G871E(&)O;VPH;W5T($1A M=&%?4&%C:V5T(&0I('L <F5T=7)N('$N8V]N<W5M92AD*3L ?2P ;G5M7W!A M8VME=',L('0L(&1E;&%Y<RD[('TI.PH)9&5B=6< >R!P<FEN=&8H(G-T87)T M:6YG(&-O;G-U;65R7&XB*3L ?0H)8V]N<W5M97(N<W1A<G0H*3L " ED96)U M9R![('!R:6YT9B B<W1A<G1E9"Y<;B(I.R!]"B` ("` ('T*"B` ("` (%1H M<F5A9$=R;W5P('!R;V1U8V5R5&AR96%D<R`](&YE=R!4:')E861'<F]U<" I M.PH ("` ("!I;G0 <'!S(#T 879G7W!A8VME='-?<&5R7W-?+VYU;5]P<F]D M=6-E<G-?.PH ("` ("!4:6-K<R!S5&EM92`]('-Y<W1I;64H*3L*("` ("` M:68 *&ES7VUP7W%U975E*'$I*2![" DO+W-P87=N(&EN<W1E860 ;V8 =&AR M96%D(&=R;W5P"B` ("` ('T*("` ("` 96QS92![" E4:')E861;72!P<F]D M=6-E<E]T:')E861S.PH)<')O9'5C97)?=&AR96%D<RYL96YG=& /2!N=6U? M<')O9'5C97)S7SL*"69O<B`H:6YT(&L],#L :SQN=6U?<')O9'5C97)S7SL M*RMK*2` >PH)("!D96)U9R![('!R:6YT9B B8W)E871I;F< )B!S=&%R=&EN M9R!P<F]D=6-E<EQN(BD[('T*"2` <')O9'5C97)?=&AR96%D<UMK72`](`H) M("` ('!R;V1U8V5R5&AR96%D<RYC<F5A=&4H>W!R;V1U8V4H9&5L96=A=&4 M=F]I9"AI;B!$871A7U!A8VME="!D*2![('$N<')O9'5C92AD*3L ?2P*"0D) M"0D ("` 9V5N+'!A8VME='-?<&5R7W!R;V1U8V5R7RQP<',L;6EC<F]S96-O M;F1?=F%R:6%B:6QI='E?*3M]*3L)("`*("` ("`*"61E8G5G('L <')I;G1F M*")S=&%R=&5D+EQN(BD[('T*"7T*("` ("` ?0H ("` ("!D96)U9R![" EP M<FEN=&8H(E=A:71I;F< 9F]R('!R;V1U8V5R<R!T;R!F:6YI<VA<;B(I.PH) M<')O9'5C97)4:')E861S+FIO:6Y!;&PH*3L ("\O('=A:70 9F]R('!R;V1U M8V5R<R!T;R!F:6YI<V *("` ("` ?0H ("` ("!D96)U9R![" EP<FEN=&8H M(D9I;FES:&5D+EQN(BD[" EP<FEN=&8H(E=A:71I;F< 9F]R(&-O;G-U;65R M('1O('-E;F0 <VEG;F%L7&XB*3L*("` ("` ?0H ("` ("!R96-E:79E*"AB M;V]L(&(I('M]*3L +R\ =V%I="!F;W( 8V]N<W5M97( =&\ 9FEN:7-H("` M("` "B` ("` (&1E8G5G('L*"7!R:6YT9B B<F5C96EV961<;B(I.PH ("` M("!]"B` ("` (%1I8VMS(&54:6UE(#T <WES=&EM92 I.PH ("` ("!R=6Y? M<U\ /2`H951I;64M<U1I;64I+G1O4V5C;VYD<R%D;W5B;&4H*3L*("` ("` M"B` ("` (&EF("AI<U]M<%]Q=65U92AQ*2D >PH)9&5L87ES+FQE;F=T:"`] M('-D96QA>7,N;&5N9W1H.PH)" EF;W( *&EN="!K/3`[(&L\<V1E;&%Y<RYL M96YG=& [("LK:RD*"2` 9&5L87ES6VM=(#T <V1E;&%Y<UMK73L*("` ("` M?0H ("` ("`*("` ("` 3E\ /2!D96QA>7,N;&5N9W1H.R`*("` ("` ("` M("` "B` ("` ('-O<G0H9&5L87ES*3L*("` ("` ;6%X:6UU;5\ /2!D96QA M>7-;9&5L87ES+FQE;F=T:"TQ73L*("` ("` ;6EN:6UU;5\ /2!D96QA>7-; M,%T["B` ("` (`H ("` ("!A=71O('-U;2`](')E9'5C92$H(F$K8B(I*&-A M<W0H;&]N9RDP+&1E;&%Y<RD["B` ("` (`H ("` ("!A=F=?(#T 8V%S="AD M;W5B;&4I<W5M+TY?.PH ("` ("`*("` ("` ;&]N9R!F*&QO;F< 82P ;&]N M9R!B*2![(`H)9&]U8FQE('$R(#T *&(M879G7RDJ*&(M879G7RD[" ER971U M<FX 82MC87-T*&QO;F<I<3([(`H ("` ("!]"B` ("` (&%U=&\ <V0 /2!R M961U8V4A*&8I*&-A<W0H;&]N9RDP+&1E;&%Y<RD["B` ("` (`H ("` ("!S M=&1?9&5V7R`]('-Q<G0H8V%S="AD;W5B;&4I<V0O3E\I.PH ("` ("`*("` M("` :6YT('!C="`](&UA>"AD96QA>7,N;&5N9W1H+S$P,"PQ*3L*("` ("` M;&]N9UM=('-M86QL97-T(#T 9&5L87ES6S` +BX <&-T73L*("` ("` ;&]N M9UM=(&QA<F=E<W0 /2!D96QA>7-;*&1E;&%Y<RYL96YG=& M<&-T*2`N+B!D M96QA>7,N;&5N9W1H73L*("` ("` 879G7VUI;E\ /2!R961U8V4A*")A*V(B M*2 P+C`L<VUA;&QE<W0I+W!C=#L*("` ("` 879G7VUA>%\ /2!R961U8V4A M*")A*V(B*2 P+C`L;&%R9V5S="DO<&-T.PH ("` ("`*("` ('T*("!]"GT* M"F%L:6%S(%%U975E7U1E<W1?5'EP97,A*&)O;VPI(%%45#L*"G9O:60 ;6%I M;B I(`I["B` <V5T8G5F*'-T9&]U="QN=6QL*3L*("!P<FEN=&8H(EQN06QL M('1I;65S(&EN(&UI8W)O<V5C;VYD<R!U;FQE<W, ;W1H97)W:7-E('-P96-I M9FEE9"Y<;B(I.PH ('!R:6YT9B B7&X\;6EN/B!A;F0 /&UA>#X 87)E(&%V M97)A9V5S(&]V97( 9F%S=&5S="!A;F0 <VQO=V5S="`Q)24 <F5S<&5C=&EV M96QY+EQN7&XB*3L*(`H (%%45"Y15"Y1=65U95M=('%U975E<SL*("`O+W%U M975E<R!^/2!N97< 4514+E%4+DQ)1D]?365S<V%G95]087-S:6YG7U%U975E M*"D["B` <75E=65S('X](&YE=R!15%0N450N3$E&3U]"=69F97)?3&]C:VEN M:V5D3&ES=%],;V-K:6YG7U%U975E*"D[(`H ('%U975E<R!^/2!N97< 4514 M+E%4+D9)1D]?3&EN:V5D3&ES=%],;V-K:6YG7U%U975E*"D[(`H ('%U975E M<R!^/2!N97< 4514+E%4+DQ)1D]?3&EN:V5D3&ES=%],;V-K1G)E95]1=65U M92 I.PH ('%U975E<R!^/2!N97< 4514+E%4+D9)1D]?3&EN:V5D3&ES=%], M;V-K1G)E95]1=65U92 I.PH*"B` 9F]R96%C:"`H43L <75E=65S*0H ("` M<')I;G1F*"(E+BIS(#T )2XJ<UQN(BQ1+FYA;64L42YD97-C<FEP=&EO;BD[ M"B` "B` <')I;G1F*")<;B(I.PH*("!15%0N475E=65?5&5S=%M=('1E<W1S M8V H=#L =&5S=',I('L*("` ('!R:6YT9B B)2XJ<UQN7&XE+BIS7&XB+'0N M5&5S=%]);F9O+'0N4G5N7TEN9F]?2&5A9&5R*3L*("` (&9O<F5A8V *%$[ M('%U975E<RD >PH ("` ("!T+G)U;BA1*3L*("` ("` <')I;G1F*"(E+BIS M7&XB+'0N4G5N7TEN9F\I.PH ("` ?0H ("` <')I;G1F*")<;B(I.PH ('T* &"GT*" H* ` end
Jan 02 2011
parent reply Sean Kelly <sean invisibleduck.org> writes:
Adam Conner-Sax Wrote:

 == Quote from Andrei Alexandrescu (SeeWebsiteForEmail erdani.org)'s article
 On 01/01/2011 06:02 PM, Adam Conner-Sax wrote:
 As a way to learn D, I am writing a quick test setup for examining different
 ways of passing data from one set of threads to another.  I am trying a few
 kinds of queues (resizeable array with locking, linked list with locking and
 lockfree with cas) and trying to also add message passing and then compare
 performance.

 Anyway, I'm running into an odd case where a thread fails to start.  The code
 simply hangs in the Threadgroup.create(...) call. I am printing (with
 unbuffered i/o) right before the call to "create" and then as soon as the
 threadfunction starts so as far as I can tell, the "create" call is made but
 the threadfunc never starts and "create" never returns.
What OS are you using? ThreadGroup.create is extremely simple, the problem is almost definitely in either the thread startup code itself or in the preamble of your supplied thread routine. What would be great is if you could produce a minimal repro. The full source you included is a bit much to easily figure out where the problem may be.
 It's repeatable but doesn't happen every time the queue is used. It happens
 sometimes when the queue is locking and sometimes when it is lockfree. I'd be
 happy to post code but for now I thought I'd just see if anyone can think of
 why that might happen or can provide some ideas for how to debug it.

 The code always starts the one consumer thread (via spawn. I'm learning!),
 then loops over the producers and creates them in a threadgroup just so I can
 do a "joinAll" to wait for them to finish.  Also, when the problem occurs,
 it's always the first producer thread that fails.  I never get 2 out of 4
 started, e.g.
If you're using std.concurrency then don't start threads manually using core.thread. The mailbox for a thread is created by spawn, and you'll get a segfault trying to send a message to a thread started using core.thread. I could change this to throw an exception instead though.
 So, in the normal case, I get matched "creating & starting..." and "started"
and
 "in produce()"
 
 In the case where it hangs, all I get is "Creating and starting..." and then it
 stays forever (or as long as I have patience to leave it).
I tried this twice. The first time I got partway into the third test and got a bus error. The second time (run via GDB) I have this on my screen and it's been this way for a while now: F,LL,Lk 8.87 64.41 970.64 0 50566 1.91 4512.36 starting consumer started. creating & starting producer in consume(...) in produce(...) Seems different from what you've experienced.
Jan 02 2011
parent reply Adam Conner-Sax <adam_conner_sax yahoo.com> writes:
Thanks for trying it!

I've seen that outcome once also but usually I don't get the "in produce(...)"
when it hangs.  And I don't get the bus errors (I've gotten them other ways).

I get that I should use spawn (and I am writing a new version to use spawn
everywhere), though I did make it all work without ever using spawn so the
mailbox
setup seems to work anyway though I do not understand how. Are both (from
spawner
to spawnee and vice versa) mailboxes set up by spawn?  How does the unit test in
std.concurrency work?  It spawns but then sends messages in both directions.

If I get the error on a smaller subset I will post.  It was all working then at
some point as I was moving toward the std.concurrency way, it all broke in the
way
I described so I don't know how to make a smaller version that also has the
error.

Adam
Jan 02 2011
parent reply Sean Kelly <sean invisibleduck.org> writes:
Adam Conner-Sax Wrote:

 Thanks for trying it!
 
 I've seen that outcome once also but usually I don't get the "in produce(...)"
 when it hangs.  And I don't get the bus errors (I've gotten them other ways).
 
 I get that I should use spawn (and I am writing a new version to use spawn
 everywhere), though I did make it all work without ever using spawn so the
mailbox
 setup seems to work anyway though I do not understand how. Are both (from
spawner
 to spawnee and vice versa) mailboxes set up by spawn?  How does the unit test
in
 std.concurrency work?  It spawns but then sends messages in both directions.
spawn creates the mailbox in the new thread. I'm going to change thisTid to create a mailbox for the current thread if none exists though. That should resolve the issue I mentioned earlier. The main thread gets a mailbox by default, if I remember correctly. I just didn't want to give other threads one by default because the ref is immediately overwritten by spawn.
 If I get the error on a smaller subset I will post.  It was all working then at
 some point as I was moving toward the std.concurrency way, it all broke in the
way
 I described so I don't know how to make a smaller version that also has the
error.
I'll try to find some time to give your code a closer look. It seems like it could be used as a more thorough test suite for the thread and messaging code.
Jan 02 2011
parent reply Adam Conner-Sax <adam_conner_sax yahoo.com> writes:
Thanks!

It's OSX, by the way.

So it's clear, I understand that message passing is preferred and I can see how
to
do that (kind of!) but I want to compare the performance to other queue
implementations so I can see that message passing is faster or comparable.

Originally, I was just trying to compare (avg and worst case latency) Locking
and
LockFree queues (and learn the basics of using CAS) but then I wanted to add
message passing to the list to compare.  Combining them all in one test harness
is
proving challenging.

That the main thread has a default mailbox makes sense and explains a lot. 
Though
I doubt I know enough to comment usefully, creating a mailbox if "thisTid" is
called makes sense to me.

Thanks again.

Adam
Jan 02 2011
parent Adam Conner-Sax <adam_conner_sax yahoo.com> writes:
Okay.  Here's a working version.  Does all the hand-coded queues in old-style
threads and the message passing via spawn.

Code attached.

FWIW, message passing is (in terms of avg and max latency) on par with the
locking
linked-list queues but the lockfree linked list queues are much faster (6x to
7x)
in all the scenarios I tried.  I'm running on a 2 x 2.8 GHz Quad-Core Intel Xeon
running Mac OS X.

Am I doing the message passing wrong somehow or is it expected to underperform
lockfree queueing if transaction speed is all that matters?

D really is great.  I haven't had this much fun programming in a while.  Thanks!

Adam
begin 644 Queue.d
M:6UP;W)T('-T9"YC+G-T9&EO.PT*:6UP;W)T(&-O<F4N871O;6EC.PT*:6UP
M;W)T('-T9"YC;VYC=7)R96YC>3L-" T*+R\ 9FER<W0 =&%K92P =7-E9"!L
M:6YK960 ;&ES=`T*+R\ ;6%Y8F4 9V5N97)A;&EZ92!M96UO<GD ;6]D96P-



M('T-"B` ("!4('9A;'5E.PT*("` ($YO9&4 ;F5X=#L-"B` ?0T*("`-"B` 

M"B` ("!V;VED('!R;V1U8V4H:6X 5"!T*3L-"B` ("!B;V]L(&-O;G-U;64H







M/2!L87-T(#T ;F5W($YO9&4[('T-"B` ("!T:&ES*"D >R!R97-E=" I.R!]

M('T-"B` ("!S=')I;F< 9&5S8W)I<'1I;VXH*2![(')E='5R;B`B1DE&3SH 
M3&]C:VEN9RP =7-I;F< 82!L:6YK960 ;&ES="!A<R!S=&]R86=E+B([('T-
M"B` ("` ("`-"B` ("!V;VED('!R;V1U8V4H:6X 5"!T*0T*("` ('L-"B` 
M("` ($YO9&4 =&UP(#T
M960 *'1H:7,I('L-" ET;7`N;F5X="`](&QA<W0N;F5X=#L-" EL87-T+FYE



M97AT.PT*"6EF("AT;7` :7, ;G5L;"D-" D (')E='5R;B!F86QS93L-" EF
M:7)S="YN97AT(#T

M" T*("!C;&%S<R!,249/7TQI;FME9$QI<W1?3&]C:VEN9U]1=65U92`Z(%%U




M(&1E<V-R:7!T:6]N*"D >R!R971U<FX (DQ)1D\Z($QO8VMI;F<L('5S:6YG





M97-U;'0I(`T*("` ('L-"B` ("` ($YO9&4 =&UP.PT*("` ("` <WEN8VAR

M:7, ;G5L;"D-" D (')E='5R;B!F86QS93L-" EL87-T+FYE>'0 /2!T;7`N
M;F5X=#L-"B` ("` ('T-"B` ("` (')E<W5L="`]('1M<"YV86QU93L-"B` 
M("` (')E='5R;B!T<G5E.PT*("` ('T-"B` ?0T*("`-" T*("!C;&%S<R!&




M*3L ?0T*("` ("` ("`-"B` ("!S=')I;F< ;F%M92 I('L <F5T=7)N(")&
M+$Q,+$Q&(CL ?0T*("` ('-T<FEN9R!D97-C<FEP=&EO;B I('L <F5T=7)N
M(")&249/.B!,;V-K($9R964 *'5S:6YG(&-A<RDL('5S:6YG(&$ ;&EN:V5D


M/2!N97< <VAA<F5D*$YO9&4I*'0I.R` ("`-"B` ("` (&1O('L-" ET;7`N
M;F5X="`](&QA<W0N;F5X=#L-"B` ("` ('T =VAI;&4 *"%C87,H)FQA<W0N



M:68 *'1M<"!I<R!N=6QL*0T*"2` <F5T=7)N(&9A;'-E.PT*("` ("` ?2!W
M:&EL92`H(6-A<R F9FER<W0N;F5X="QT;7`L=&UP+FYE>'0I*3L-"B` ("` 
M(`T*("` ("` <F5S=6QT(#T =&UP+G9A;'5E.PT*("` ("` <F5T=7)N('1R


M("!S:&%R960 3F]D92!L87-T.PT*("` ("` ("`-"B` <'5B;&EC. T*("` 

M("` =&AI<R I('L <F5S970H*3L ?0T*("` ("` ("`-"B` ("!S=')I;F< 
M;F%M92 I('L <F5T=7)N("),+$Q,+$Q&(CL ?0T*("` ('-T<FEN9R!D97-C
M<FEP=&EO;B I('L <F5T=7)N("),249/.B!,;V-K($9R964 *'5S:6YG(&-A


M("!S:&%R960 875T;R!T;7` /2!N97< <VAA<F5D*$YO9&4I*'0I.R` ("`-
M"B` ("` (&1O('L-" ET;7`N;F5X="`](&QA<W0N;F5X=#L-"B` ("` ('T 
M=VAI;&4 *"%C87,H)FQA<W0N;F5X="QT;7`N;F5X="QT;7`I*3L-"B` ("!]

M("` >PT*("` ("` <VAA<F5D($YO9&4 =&UP.PT*("` ("` 9&\ >PT*"71M
M<"`](&QA<W0N;F5X=#L-







M<W1R:6YG(&1E<V-R:7!T:6]N*"D >R!R971U<FX (DQ)1D\Z($QO8VMI;F<L
M('5S:6YG(&$ 9'EN86UI8V%L;'D <F5S:7IA8FQE(&%R<F%Y(&%S('-T;W)A

M/3$P,"D-"B` ("` ('L-" ES=&%R=&EN9U]B=69F97)?9&5P=&A?(#T <W1A


M=&%R=&EN9U]B=69F97)?9&5P=&A?73L-"B` ("` (&-U<G)E;G1?(#T )F)U



M:7,I('L-" DJ*&-U<G)E;G1?*RLI(#T =#L-" T*"6EF("AC=7)R96YT7R`]
M/2`F8G5F9F5R7UMB=69F97)?+FQE;F=T:"TQ72D >PT*"2` :6YT(&P /2!B
M=69F97)?+FQE;F=T:#L-" D (&)U9F9E<E\N;&5N9W1H(#T
M(')E<VEZ90T*"2` 8W5R<F5N=%\ /2`F8G5F9F5R7UML+3%=.R`O+R!R97!O
M:6YT(&%T(&5N9"`-" D ('!R:6YT9B B8G5F9F5R(')E<VEZ960 =&\ )6E<

M?0T*("` (`T*("` (&)O;VP 8V]N<W5M92AO=70 5"!R97-U;'0I(`T*("` 




M97-S86=E7U!A<W-I;F=?475E=64 .B!-97-S86=E7U!A<W-I;F=?475E=64 

M<'5B;&EC. T*("` (`T*("` ('-T<FEN9R!N86UE*"D >R!R971U<FX (D8L

M1D\Z($UE<W-A9V4 4&%S<VEN9R([('T-"B` ("!4:60 8V]N<W5M97)?5&ED
M*"D >R!R971U<FX 8V]N<W5M97)?=&ED7SL ?0T*("` ('9O:60 <V5T7V-O

M*")-4#H
M("!C;VYS=6UE<E]T:61?(#T =#L-

M(%0 ="D >PT*("` ("` <V5N9"AC;VYS=6UE<E]T:61?+'0I.PT*("` ('T-

M("!R96-E:79E*"A4('0I('L <F5S=6QT(#T =#L

`
end
begin 644 Queue_Test_ThreadObjects.d
M:6UP;W)T('-T9"YC+G-T9&EO.PII;7!O<G0 8V]R92YT:')E860["FEM<&]R
M="!S=&0N9&%T971I;64["FEM<&]R="!S=&0N<F%N9&]M.PII;7!O<G0 <W1D
M+FUA=& ["FEM<&]R="!S=&0N86QG;W)I=&AM.PII;7!O<G0 <W1D+F9O<FUA
M=#L*:6UP;W)T('-T9"YR86YG93L*:6UP;W)T('-T9"YC;VYC=7)R96YC>3L*
M:6UP;W)T('-T9"YT<F%I=',["FEM<&]R="!S=&0N8V]N8W5R<F5N8WD[" H*
M:6UP;W)T(%%U975E.PH*=&5M<&QA=&4 475E=65?5&5S=%]4>7!E<RA4*2`*
M>PH ('-T<G5C="!$871A7U!A8VME="`*("!["B` ("!4:6-K<R!P5&EM93L*
M("` (&)O;VP ;&%S="`](&9A;'-E.PH ("` 5"!D=6UM>3L*("!]" H (&%L
M:6%S(%%U975E7U1Y<&5S(2A$871A7U!A8VME="D 450[" H ('1E;7!L871E
M(%%U975E7U5S92`H42D "B` >PH ("` =F]I9"!S96YD7W1O*%$ <2P :6X 
M1&%T85]086-K970 9"D >R!Q+G!R;V1U8V4H9"D[('T*("` (&)O;VP <F5C
M96EV95]F<F]M*%$ <2P ;W5T($1A=&%?4&%C:V5T(')E<W5L="D >R!R971U
M<FX <2YC;VYS=6UE*&0I.R!]"B` ?0H*("!C;&%S<R!0<F]D=6-E<CH 5&AR
M96%D"B` >PH ("` =&AI<RA15"Y1=65U92!Q+"!286YD;VT <BP :6YT('!A
M8VME=',L(&EN="!P86-K971S7W!E<E]S+"!I;G0 =7-?=F%R:6%B:6QI='DI
M(`H ("` >PH ("` ("!17R`]('$["B` ("` (')?(#T <CL*("` ("` <&%C


M+R\ ;6%K92!S=7)E('=E(&-A;B=T(&AA=F4 +71V92!S;&5E<`H ("` ("!P
M86-K971?=F%R:6%B:6QI='E?(#T
M8VME=%]S<&%C:6YG7RD["B` ("` ('-U<&5R*"9R=6XI.R` "B` ("!]"B` 
M<')I=F%T93H*("` (&EN="!P86-K971S7SL*("` (&EN="!P86-K971?<W!A
M8VEN9U\["B` ("!I;G0 <&%C:V5T7W9A<FEA8FEL:71Y7SL*("` (%%4+E%U
M975E(%%?.PH ("` 4F%N9&]M(')?.PH ("` "B` ("!V;VED(')U;B I(`H 
M("` >PH ("` ("!D96)U9R Q*2![('!R:6YT9B B:6X <')O9'5C92 I7&XB

M=&5R*RL /"!P86-K971S7RD ('L*"41A=&%?4&%C:V5T(&1A=&$[" ED871A
M+G!4:6UE(#T
M:6YG('0])6E<;B(L9&%T82YP5&EM92YV86QU92D[('T*"5%?+G!R;V1U8V4H
M9&%T82D[" ET:&ES+G-L965P*'!A8VME=%]S<&%C:6YG7RMU;FEF;W)M*"UP
M86-K971?=F%R:6%B:6QI='E?+'!A8VME=%]V87)I86)I;&ET>5\L<E\I*3L*
M("` ("` ?0H ("` ?0H ('T*"B` <W1R=6-T(%!R;V1U8V5R7TU07T1O;F4 
M>WT["B` "B` =F]I9"!P<F]D=6-E7VUP*&EN="!P86-K971S+"!I;G0 <&%C
M:V5T<U]P97)?<RP 4F%N9&]M('(L(&EN="!U<U]V87)I86)I;&ET>2P 5&ED
M(&-4:60L(%1I9"!M5&ED*2`*("!["B` ("!D96)U9R Q*2![('!R:6YT9B B
M:6X <')O9'5C95]M<" I7&XB*3L ?0H ("` :6YT(&-O=6YT97( /2`P.PH 
M("` 8V]N<W0 :6YT('!A8VME=%]S<&%C:6YG(#T
M<U]P97)?<SL +R]U;FET<R!A<F4 ,3`P;G, "B` ("!C;VYS="!I;G0 <&%C
M:V5T7W9A<FEA8FEL:71Y(#T
M=%]S<&%C:6YG*3L*("` ('=H:6QE("AC;W5N=&5R*RL /"!P86-K971S*2` 
M>PH)1&%T85]086-K970 9&%T83L*"61A=&$N<%1I;64 /2!S>7-T:6UE*"D[
M" ED96)U9R`H-2D >R!P<FEN=&8H(E-E;F1I;F< =#TE:5QN(BQD871A+G!4
M:6UE+G9A;'5E*3L ?0H)<V5N9"AC5&ED+&1A=&$I.PH)5&AR96%D+G-L965P
M*'!A8VME=%]S<&%C:6YG*W5N:69O<FTH+7!A8VME=%]V87)I86)I;&ET>2QP
M86-K971?=F%R:6%B:6QI='DL<BDI.PH ("` ?0H ("` 4')O9'5C97)?35!?
M1&]N92!P9#L*("` ('-E;F0H;51I9"QP9"D["B` ("!D96)U9R Q*2![('!R
M:6YT9B B96YD('!R;V1U8V5?;7`H*5QN(BD[('T*("!]" H ("`*("!15"Y-
M97-S86=E7U!A<W-I;F=?475E=64 ;7!?<75E=64H450N475E=64 <2D >PH 
M("` 450N365S<V%G95]087-S:6YG7U%U975E(&UP<2`](&-A<W0H450N365S
M<V%G95]087-S:6YG7U%U975E*7$["B` ("!R971U<FX ;7!Q.PH ('T*("`*

M=64 <2QI;G0 =&]T86Q?97AP96-T961?<&%C:V5T<RD "B` ("` ('L*"5%?
M(#T <3L*"65X<&5C=&5D7W!A8VME='-?(#T =&]T86Q?97AP96-T961?<&%C
M:V5T<SL*"61E;&%Y<U\N;&5N9W1H(#T =&]T86Q?97AP96-T961?<&%C:V5T
M<SL*"7-U<&5R*"9R=6XI.PH ("` ("!]"B` ("!B;V]L('-T;W` /2!F86QS
M93L*("!P<FEV871E. H ("` 450N475E=64 45\["B` ("!L;VYG6UT 9&5L
M87ES7SL*("` (&EN="!E>'!E8W1E9%]P86-K971S7SL*"B` ("!V;VED(')U
M;B I(`H ("` >PH ("` ("!D96)U9R Q*2![('!R:6YT9B B:6X 8V]N<W5M

M($1A=&%?4&%C:V5T(&1A=&$["B` ("` ('=H:6QE("AP86-K971?;G5M8F5R
M(#P 97AP96-T961?<&%C:V5T<U\I('L*"6EF("A17RYC;VYS=6UE*&1A=&$I
M*2![" D (&1E;&%Y<U];<&%C:V5T7VYU;6)E<BLK72`]('!A8VME=%]D96QA
M>2AD871A*3L*"7T*("` ("` ?0H ("` ("!D96)U9R Q*2![('!R:6YT9B B
M96YD(&-O;G-U;64H*5QN(BD[('T*("` ('T*"B` <'5B;&EC. H ("` ;&]N
M9UM=(&1E;&%Y<R I('L <F5T=7)N(&1E;&%Y<U\[('T*("!]" H (&QO;F< 
M<&%C:V5T7V1E;&%Y*$1A=&%?4&%C:V5T(&1A=&$I(`H ('L*("` (&1E8G5G
M(" U*2![('!R:6YT9B B4F5C)V0 =#TE:5QN(BQD871A+G!4:6UE+G9A;'5E
M*3L ?0H ("` 5&EC:W, 8U1I;64["B` ("!C5&EM92`]('-Y<W1I;64H*3L 
M"B` ("!D96)U9R`H-2D >R!P<FEN=&8H(E)E8R=D(&%T('0])6E<;B(L8U1I
M;64N=F%L=64I.R!]"B` ("!4:6-K<R!E;&%P<V5D(#T 8U1I;64 +2!D871A
M+G!4:6UE.PH ("` ;&]N9R!E;&%P<V5D7W5S(#T 96QA<'-E9"YT;TUI8W)O
M<V5C;VYD<R$H;&]N9RDH*3L*("` (')E='5R;B!E;&%P<V5D7W5S.PH ("` 

M('T*"B` <W1R=6-T($-O;G-U;65?35!?1&]N92![?3L*"B` =F]I9"!C;VYS
M=6UE7VUP*&EN="!N=6U?<&%C:V5T<RP 5&ED(&U4:60L('-H87)E9"!L;VYG
M6UT <V1E;&%Y<RD "B` >PH ("` 9&5B=6<H,2D >R!P<FEN=&8H(FEN(&-O
M;G-U;65?;7`H*5QN(BD[('T*("` (&EN="!P86-K971?;G5M8F5R(#T ,#L*
M("` ('=H:6QE("AP86-K971?;G5M8F5R(#P ;G5M7W!A8VME=',I"B` ("` 
M(')E8V5I=F4H*$1A=&%?4&%C:V5T(&0I('MS9&5L87ES6W!A8VME=%]N=6UB

M7TU07T1O;F4 8V0["B` ("!S96YD*&U4:60L8V0I.PH ("` 9&5B=6<H,2D 
M>R!P<FEN=&8H(F5N9"!C;VYS=6UE7VUP*"E<;B(I.R!]"B` ?0H (`H (&-L
M87-S(%%U975E7U1E<W0 >PH ("` :6UM=71A8FQE('-T<FEN9R!497-T7TEN
M9F]?2&5A9&5R(#T (E!R;V1S7'1P:W1S7%QP<F]D7'1P:W1S7%QS7'1J:71T
M97(B.PH ("` :6UM=71A8FQE('-T<FEN9R!2=6Y?26YF;U](96%D97( /2`B
M475E=65<="!4;W0 <UQT(&%V9UQT("!S9%QT;6EN7'0 ;6%X7'0\;6EN/EQT
M(#QM87 ^7&Y?7U]?7U]<=%]?7U]?7UQT7U]?7U]<=%]?7U]?7'1?7U]<=%]?
M7U]?7'1?7U]?7UQT7U]?7U]?7R([" H ("` +R]S=&%T:6, <W1R:6YG(%1E
M<W1?26YF;U](96%D97(H*2![(')E='5R;B!I;6UU=&%B;&4 <W1R:6YG*")0
M<F]D<UQT<&MT<UQ<<')O9%QT<&MT<UQ<<UQT:FET=&5R(BD[('T*("` ("\O
M<W1A=&EC('-T<FEN9R!2=6Y?26YF;U](96%D97(H*2![(')E='5R;B!I;6UU
M=&%B;&4 <W1R:6YG*")1=65U95QT5&]T('-<=%1O="!P:W1S7'1A=F=<='-D
M7'1M:6Y<=&UA>%QT/&UI;CY<=#QM87 ^(CL ?0H ("` "B` <')I=F%T93H*
M("` (`H ("` +R\ 9F]R('1E<W0 :6YP=71S"B` ("!I;G0 ;G5M7W!R;V1U
M8V5R<U\L('!A8VME='-?<&5R7W!R;V1U8V5R7RP 879G7W!A8VME='-?<&5R
M7W-?+"!M:6-R;W-E8V]N9%]V87)I86)I;&ET>5\["B` ("`*("` ("\O(&9O
M<B!T97-T(&]U='!U=',*("` (&QO;F< ;6%X:6UU;5\L;6EN:6UU;5\L3E\[
M"B` ("!D;W5B;&4 879G7RP <W1D7V1E=E\L(&%V9U]M:6Y?+"!A=F=?;6%X
M7RP <G5N7W-?.PH ("` <W1R:6YG('%?;F%M95\["B` ("`*("!P=6)L:6,Z
M"B` ("!T:&ES*&EN="!N=6U?<')O9'5C97)S+"!I;G0 <&%C:V5T<U]P97)?
M<')O9'5C97(L(&EN="!A=F=?<&%C:V5T<U]P97)?<RP :6YT(&UI8W)O<V5C
M;VYD7W9A<FEA8FEL:71Y*2`*("` ('L*("` ("` ;G5M7W!R;V1U8V5R<U\ 
M/2!N=6U?<')O9'5C97)S.PH ("` ("!P86-K971S7W!E<E]P<F]D=6-E<E\ 
M/2!P86-K971S7W!E<E]P<F]D=6-E<CL*("` ("` 879G7W!A8VME='-?<&5R
M7W-?(#T 879G7W!A8VME='-?<&5R7W,["B` ("` (&UI8W)O<V5C;VYD7W9A
M<FEA8FEL:71Y7R`](&UI8W)O<V5C;VYD7W9A<FEA8FEL:71Y.PH ("` ?0H 
M("` "B` ("!S=')I;F< 5&5S=%]);F9O*"D >R`*("` ("` 875T;R!W<FET
M97( /2!A<'!E;F1E<B%S=')I;F<H*3L)("` (`H ("` ("!F;W)M871T9617
M<FET92AW<FET97(L(B5S('!R;V1U8V5R*',I(&5A8V  <')O9'5C:6YG("5S
M('!A8VME=', 870 )7, <&MT<R]S("AT;W1A;"D =VET:"`E<R!U<R!J:71T
M97(Z(BQN=6U?<')O9'5C97)S7RQP86-K971S7W!E<E]P<F]D=6-E<E\L879G
M7W!A8VME='-?<&5R7W-?+&UI8W)O<V5C;VYD7W9A<FEA8FEL:71Y7RD["B` 
M("` (')E='5R;B!W<FET97(N9&%T83L*("` ('T*("` (`H ("` "B` ("!S
M=')I;F< 4G5N7TEN9F\H*2!["B` ("` (&%U=&\ =W)I=&5R(#T 87!P96YD
M97(A<W1R:6YG*"D["B` ("` (&9O<FUA='1E9%=R:71E*'=R:71E<BPB)7-<
M="4V+C)F7'0E-2XR9EQT)34N,F9<="4R<R(L<5]N86UE7RQR=6Y?<U\L879G
M7RQS=&1?9&5V7RQM:6YI;75M7RD["B` ("` (&9O<FUA='1E9%=R:71E*'=R
M:71E<BPB7'0E-7,B+"!M87AI;75M7RD["B` ("` (&9O<FUA='1E9%=R:71E
M*'=R:71E<BPB7'0E-2XR9B(L879G7VUI;E\I.PH ("` ("!F;W)M871T9617
M<FET92AW<FET97(L(EQT)3<N,F8B+&%V9U]M87A?*3L*("` ("` <F5T=7)N
M('=R:71E<BYD871A.PH ("` ?0H ("`*"B` ("!V;VED(')U;BA15"Y1=65U
M92!Q*0H ("` >PH ("` ("!Q7VYA;65?(#T <2YN86UE.PH ("` ("!Q+G)E
M<V5T*"D["B` ("` ("\O(&-R96%T92!A('!R;V1U8V5R('1H<F5A9"!A;F0 
M82!C;VYS=6UE<B!T:')E860*("` ("` 4F%N9&]M(&=E;CL*("` ("` 8V]N
M<W0 :6YT(&YU;6)E<E]P86-K971S(#T ;G5M7W!R;V1U8V5R<U\J<&%C:V5T
M<U]P97)?<')O9'5C97)?.PH ("` ("!4:60 ;51I9"`]('1H:7-4:60H*3L*
M" H ("` ("!15"Y-97-S86=E7U!A<W-I;F=?475E=64 ;7!Q(#T ;7!?<75E
M=64H<2D["B` ("` ($-O;G-U;65R(&-O;G-U;65R.PH ("` ("!S:&%R960 
M;&]N9UM=('-D96QA>7,["B` ("` (%1I9"!C5&ED.PH ("` ("!S9&5L87ES
M+FQE;F=T:"`](&YU;6)E<E]P86-K971S.PH ("` ("!I9B`H;7!Q("%I<R!N
M=6QL*2![" ED96)U9R Q*2![('!R:6YT9B B4W!A=VYI;F< 8V]N<W5M97( 
M=&AR96%D+EQN(BD[('T*"6-4:60 /2!S<&%W;B F8V]N<W5M95]M<"QN=6UB
M97)?<&%C:V5T<RQM5&ED+'-D96QA>7,I.PH);7!Q+G-E=%]C;VYS=6UE<E]4
M:60H8U1I9"D[" ED96)U9R Q*2![('!R:6YT9B B8V]N<W5M97( =&AR96%D
M('-P87=N960N7&XB*3L ?0H ("` ("!]"B` ("` (&5L<V4 >PH)9&5B=6<H
M,2D >R!P<FEN=&8H(E-T87)T:6YG(&-O;G-U;65R('1H<F5A9"Y<;B(I.R!]

M+R\ ;VYE(&-O;G-U;65R(`H)8V]N<W5M97(N<W1A<G0H*3L " ED96)U9R Q
M*2![('!R:6YT9B B8V]N<W5M97( <W1A<G1E9"XB*3L ?0H ("` ("!]"B` 
M("` ("` " H ("` ("!C;VYS="!I;G0 <'!S(#T 879G7W!A8VME='-?<&5R
M7W-?+VYU;5]P<F]D=6-E<G-?.PH ("` ("!4:6-K<R!S5&EM92`]('-Y<W1I
M;64H*3L*("` ("` :68 *&UP<2`A:7, ;G5L;"D >PH)9F]R("AI;G0 :STP
M.R!K/&YU;5]P<F]D=6-E<G-?.R`K*VLI('L*"2` 9&5B=6<H,2D >R!P<FEN
M=&8H(G-P87=N:6YG('!R;V1U8V5R+EQN(BD[('T*"2` <W!A=VXH)G!R;V1U
M8V5?;7`L<&%C:V5T<U]P97)?<')O9'5C97)?+'!P<RQG96XL;6EC<F]S96-O


M<')I;G1F*")786ET:6YG(&9O<B!P<F]D=6-E<G, =&\ <VEG;F%L(&1O;F4N
M7&XB*3L ?0H)9F]R("AI;G0 :STP.R!K/&YU;5]P<F]D=6-E<G-?.R`K*VLI
M('L*"2` <F5C96EV92 H4')O9'5C97)?35!?1&]N92!P9"D >WTI.PH)?0H)
M9&5B=6<H,2D >R!P<FEN=&8H(F%L;"!P<F]D=6-E<G, <VEG;F%L960N7&XB
M*3L ?0H ("` ("!]"B` ("` (&5L<V4 >PH)5&AR96%D1W)O=7` <')O9'5C
M97)4:')E861S(#T ;F5W(%1H<F5A9$=R;W5P*"D[" EF;W( *&EN="!K/3`[
M(&L\;G5M7W!R;V1U8V5R<U\[("LK:RD >PH)("!A=71O('!R;V1U8V5R(#T 
M;F5W(%!R;V1U8V5R*'$L9V5N+'!A8VME='-?<&5R7W!R;V1U8V5R7RQP<',L
M;6EC<F]S96-O;F1?=F%R:6%B:6QI='E?*3L*"2` 9&5B=6<H,2D >R!P<FEN
M=&8H(G-T87)T:6YG('!R;V1U8V5R+EQN(BD[('T*"2` <')O9'5C97(N<W1A
M<G0H*3L*"2` 9&5B=6<H,2D >R!P<FEN=&8H(G!R;V1U8V5R('-T87)T960N
M7&XB*3L ?0H)("!P<F]D=6-E<E1H<F5A9',N861D*'!R;V1U8V5R*3L*"7T*

M*3L ?0H)<')O9'5C97)4:')E861S+FIO:6Y!;&PH*3L (`H)9&5B=6<H,2D 
M>R!P<FEN=&8H(G!R;V1U8V5R<R!F:6YI<VAE9"Y<;B(I.R!]"B` ("` ('T*
M("` ("` "B` ("` (&EF("AM<'$ (6ES(&YU;&PI('L " ED96)U9R Q*2![
M('!R:6YT9B B5V%I=&EN9R!F;W( *'-P87=N960I(&-O;G-U;65R('1H<F5A


M:6=N86QE9"Y<;B(I.R!]"B` ("` ('T*("` ("` 96QS92![" ED96)U9R Q
M*2![('!R:6YT9B B5V%I=&EN9R!F;W( 8V]N<W5M97( =&AR96%D+EQN(BD[
M('T*"6-O;G-U;65R+G-T;W` /2!T<G5E.PH)8V]N<W5M97(N:F]I;B I.R`O

M;VYS=6UE<B!F:6YI<VAE9"Y<;B(I.R!]"B` ("` ('T*" H ("` ("!4:6-K
M<R!E5&EM92`]('-Y<W1I;64H*3L*("` ("` <G5N7W-?(#T *&54:6UE+7-4
M:6UE*2YT;U-E8V]N9',A9&]U8FQE*"D["B` ("` (`H ("` ("!L;VYG6UT 
M9&5L87ES.PH ("` ("!I9B`H;7!Q("%I<R!N=6QL*2`*"61E;&%Y<R`](&-A
M<W0H;&]N9UM=*7-D96QA>7,["B` ("` (&5L<V4*"61E;&%Y<R`](&-O;G-U
M;65R+F1E;&%Y<R I.PH ("` ("`*"B` ("` ($Y?(#T 9&5L87ES+FQE;F=T
M:#L "B` ("` (`H ("` ("`*("` ("` "B` ("` ('-O<G0H9&5L87ES*3L*
M("` ("` ;6%X:6UU;5\ /2!D96QA>7-;9&5L87ES+FQE;F=T:"TQ73L*("` 
M("` ;6EN:6UU;5\ /2!D96QA>7-;,%T["B` ("` (`H ("` ("!A=71O('-U
M;2`](')E9'5C92$H(F$K8B(I*&-A<W0H;&]N9RDP+&1E;&%Y<RD["B` ("` 
M(`H ("` ("!A=F=?(#T 8V%S="AD;W5B;&4I<W5M+TY?.PH ("` ("`*("` 
M("` ;&]N9R!F*&QO;F< 82P ;&]N9R!B*2![(`H)9&]U8FQE('$R(#T *&(M
M879G7RDJ*&(M879G7RD[" ER971U<FX 82MC87-T*&QO;F<I<3([(`H ("` 
M("!]"B` ("` (&%U=&\ <V0 /2!R961U8V4A*&8I*&-A<W0H;&]N9RDP+&1E
M;&%Y<RD["B` ("` (`H ("` ("!S=&1?9&5V7R`]('-Q<G0H8V%S="AD;W5B
M;&4I<V0O3E\I.PH ("` ("`*("` ("` :6YT('!C="`](&UA>"AD96QA>7,N
M;&5N9W1H+S$P,"PQ*3L*("` ("` ;&]N9UM=('-M86QL97-T(#T 9&5L87ES
M6S` +BX <&-T73L*("` ("` ;&]N9UM=(&QA<F=E<W0 /2!D96QA>7-;*&1E
M;&%Y<RYL96YG=& M<&-T*2`N+B!D96QA>7,N;&5N9W1H73L*("` ("` 879G
M7VUI;E\ /2!R961U8V4A*")A*V(B*2 P+C`L<VUA;&QE<W0I+W!C=#L*("` 
M("` 879G7VUA>%\ /2!R961U8V4A*")A*V(B*2 P+C`L;&%R9V5S="DO<&-T
M.PH ("` ("`*("` ('T*("!]"GT*"F%L:6%S(%%U975E7U1E<W1?5'EP97,A
M*&)O;VPI(%%45#L*"G9O:60 ;6%I;B I(`I["B` <V5T8G5F*'-T9&]U="QN
M=6QL*3L*("!P<FEN=&8H(EQN06QL('1I;65S(&EN(&UI8W)O<V5C;VYD<R!U
M;FQE<W, ;W1H97)W:7-E('-P96-I9FEE9"Y<;B(I.PH ('!R:6YT9B B7&X\
M;6EN/B!A;F0 /&UA>#X 87)E(&%V97)A9V5S(&]V97( 9F%S=&5S="!A;F0 
M<VQO=V5S="`Q)24 <F5S<&5C=&EV96QY+EQN7&XB*3L*(`H (%%45"Y15"Y1
M=65U95M=('%U975E<SL*("!Q=65U97, ?CT ;F5W(%%45"Y15"Y,249/7T)U

M450N3$E&3U],:6YK961,:7-T7TQO8VMI;F=?475E=64H*3L "B` <75E=65S
M('X](&YE=R!15%0N450N1DE&3U],:6YK961,:7-T7TQO8VMI;F=?475E=64H
M*3L "B` <75E=65S('X](&YE=R!15%0N450N3$E&3U],:6YK961,:7-T7TQO
M8VM&<F5E7U%U975E*"D["B` "B` <75E=65S('X](&YE=R!15%0N450N1DE&
M3U],:6YK961,:7-T7TQO8VM&<F5E7U%U975E*"D["B` <75E=65S('X](&YE
M=R!15%0N450N1DE&3U]-97-S86=E7U!A<W-I;F=?475E=64H*3L*"B` 9F]R
M96%C:"`H43L <75E=65S*0H ("` <')I;G1F*"(E+BIS(#T )2XJ<UQN(BQ1
M+FYA;64L42YD97-C<FEP=&EO;BD["B` "B` <')I;G1F*")<;B(I.PH*("!1
M5%0N475E=65?5&5S=%M=('1E<W1S.PH (`H ('1E<W1S('X](&YE=R!15%0N










M"B` " H (&9O<F5A8V H=#L =&5S=',I('L*("` ('!R:6YT9B B)2XJ<UQN
M7&XE+BIS7&XB+'0N5&5S=%]);F9O+'0N4G5N7TEN9F]?2&5A9&5R*3L*("` 
M(&9O<F5A8V  *%$[('%U975E<RD >PH ("` ("!T+G)U;BA1*3L*("` ("` 
M<')I;G1F*"(E+BIS7&XB+'0N4G5N7TEN9F\I.PH ("` ?0H ("` <')I;G1F
2*")<;B(I.PH ('T*"GT*" H*
`
end
Jan 02 2011