ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     
^c           @   s   d  d l  Z  d d d     YZ d d d     YZ d d d     YZ d d d	     YZ d
 d d     YZ d   Z d   Z d   Z d   Z	 d   Z
 d   Z e d k r e   n  d S(   iNt	   conditionc           B   sD   e  Z d d   Z d   Z d   Z d   Z d   Z d d  Z RS(   c         C   s   | d  k r t j   |  _ n3 t | d  rH t | d  rH | |  _ n	 t d  t j   |  _ |  j j   t j   |  _ d |  _	 d |  _
 d |  _ d |  _ d |  _ d  S(   Nt   acquiret   releases.   condition constructor requires a lock argumenti    (   t   Nonet   threadt   allocate_lockt   mutext   hasattrt	   TypeErrort   checkoutR   t   idlockt   idt   waitingt   pendingt	   toreleaset	   releasing(   t   selft   lock(    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   __init__  s    					c         C   s   |  j  j   d  S(   N(   R   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR   *  s    c         C   s   |  j  j   d  S(   N(   R   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR   -  s    c         C   s3  |  j  |  j |  j } } } | j   s5 t d  n  | j   |  j } |  j d |  _ | j   | j   x? | j   | j   | |  j k  r Pn  | j   | j   qo W|  j	 d |  _	 |  j
 d |  _
 |  j
 r | j   n7 d |  _ |  j	 |  j k o
d k n rd |  _ n  | j   | j   d  S(   Ns1   condition must be .acquire'd when .wait() invokedi   i    (   R   R	   R
   t   lockedt
   ValueErrorR   R   R   R   R   R   R   (   R   R   R	   R
   t   myid(    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   wait0  s2    	
	


 

 		"
c         C   s   |  j  d  d  S(   Ni   (   t	   broadcast(   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   signalN  s    ic         C   s   | d k  r t  d | f  n  | d k r/ d  S|  j j   |  j rt |  j |  j |  _ d |  _ |  j d |  _ n  | d k r |  j |  _ n t |  j |  j |  |  _ |  j r |  j r d |  _ |  j	 j
   n  |  j j
   d  S(   Nis   .broadcast called with num %ri    i   (   R   R
   R   R   R   R   R   t   minR   R	   R   (   R   t   num(    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR   Q  s"    				N(	   t   __name__t
   __module__R   R   R   R   R   R   R   (    (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR      s   				t   barrierc           B   s   e  Z d    Z d   Z RS(   c         C   s"   | |  _  | |  _ t   |  _ d  S(   N(   t   nt   togoR    t   full(   R   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR   f  s    		c         C   s]   |  j  } | j   |  j d |  _ |  j r9 | j   n |  j |  _ | j   | j   d  S(   Ni   (   R    R   R   R   R   R   R   (   R   R    (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   enterk  s    	
	
(   R   R   R   R!   (    (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR   e  s   	t   eventc           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   s   d |  _  t   |  _ d  S(   Ni    (   t   stateR    t   posted(   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR   w  s    	c         C   s4   |  j  j   d |  _ |  j  j   |  j  j   d  S(   Ni   (   R$   R   R#   R   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   post{  s    	c         C   s'   |  j  j   d |  _ |  j  j   d  S(   Ni    (   R$   R   R#   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   clear  s    	c         C   s'   |  j  j   |  j } |  j  j   | S(   N(   R$   R   R#   R   (   R   t   answer(    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt	   is_posted  s    	c         C   s7   |  j  j   |  j s& |  j  j   n  |  j  j   d  S(   N(   R$   R   R#   R   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR     s    	(   R   R   R   R%   R&   R(   R   (    (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR"   v  s
   				t	   semaphorec           B   s&   e  Z d  d  Z d   Z d   Z RS(   i   c         C   s>   | d k r t  d |  n  | |  _ | |  _ t   |  _ d  S(   Ni    s    semaphore count %d; must be >= 1(   R   t   countt   maxcountR    t   nonzero(   R   R*   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR     s
    		c         C   sQ   |  j  j   x  |  j d k r/ |  j  j   q W|  j d |  _ |  j  j   d  S(   Ni    i   (   R,   R   R*   R   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   p  s
    c         C   s`   |  j  j   |  j |  j k r2 t d |  j  n  |  j d |  _ |  j  j   |  j  j   d  S(   Ns:   .v() tried to raise semaphore count above initial value %ri   (   R,   R   R*   R+   R   R   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   v  s    (   R   R   R   R-   R.   (    (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR)     s   	t   mrswc           B   s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   sR   t  j   |  _ d |  _ d |  _ d |  _ t |  j  |  _ t |  j  |  _ d  S(   Ni    (	   R   R   t   rwOKt   nrt   nwt   writingR    t   readOKt   writeOK(   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR     s    			c         C   sK   |  j  j   x |  j r) |  j j   q W|  j d |  _ |  j  j   d  S(   Ni   (   R0   R   R2   R4   R   R1   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   read_in  s
    c         C   sh   |  j  j   |  j d k r( t d  n  |  j d |  _ |  j d k rW |  j j   n  |  j  j   d  S(   Ni    s,   .read_out() invoked without an active readeri   (   R0   R   R1   R   R5   R   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   read_out  s    	c         C   s]   |  j  j   |  j d |  _ x# |  j s2 |  j rB |  j j   q  Wd |  _ |  j  j   d  S(   Ni   (   R0   R   R2   R3   R1   R5   R   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   write_in  s    	c         C   sr   |  j  j   |  j s" t d  n  d |  _ |  j d |  _ |  j rT |  j j   n |  j j   |  j  j	   d  S(   Ns-   .write_out() invoked without an active writeri    i   (
   R0   R   R3   R   R2   R5   R   R4   R   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt	   write_out  s    				c         C   su   |  j  j   |  j s" t d  n  d |  _ |  j d |  _ |  j d |  _ |  j sd |  j j   n  |  j  j   d  S(   Ns1   .write_to_read() invoked without an active writeri    i   (	   R0   R   R3   R   R2   R1   R4   R   R   (   R   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   write_to_read  s    				(   R   R   R   R6   R7   R8   R9   R:   (    (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyR/     s   			
		c         G   sy   t  j   t d } a t  j   t j   t j |  d G| Gd Gt t  Gd GHt j   t j	 |  | f |  d  S(   Ni   s   starting threads   --t   alive(
   t   tidR   t   TIDR   t   ioR;   t   appendt   lenR   t   start_new_thread(   t   funct   argsR   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   _new_thread  s    
  

 
c   
      C   sW  t  j   d G|  Gd G| G| GHt  j   | | d k r| | } | d } xQ t | |  D]@ } | | | k r] | | | | | | <| | <| d } q] q] W| | d | | | <| | d <t   } t   }	 t t | | | d |  t t | | | |	  | j   |	 j   n  t  j   d G|  Gd GHt j	 |   t  j   | j
   d  S(   NR   t   qsorti   s
   qsort done(   R>   R   R   t   rangeR"   RD   t   _qsortR   R;   t   removeR%   (
   R<   t   at   lt   rt   finishedt   pivott   jt   it   l_subarray_sortedt   r_subarray_sorted(    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyRG     s,    
  


!		

  
c         C   s   t  j   d G|  Gd GHt  j   x] t d t |   D]F } t j   t d |  } t j   | | | | | | <| | <q7 Wt  j   d G|  Gd GHt j |   t  j   | j	   d  S(   NR   s   randomizing arrayi   i    s   randomizing done(
   R>   R   R   RF   R@   t   wht   randintR;   RH   R%   (   R<   RI   RL   RO   RN   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt
   _randarray  s    
 

  
!
  
c         C   s.   |  t  t |    k r* t d |  f  n  d  S(   Ns   a not sorted(   RF   R@   R   (   RI   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   _check_sort  s    c         C   s6  t  j   d G|  Gd G| GHt  j   t   } t t | |  | j   t  j   d G|  Gd G| GHt  j   | j   t t | d t	 |  |  | j   t
 |  t  j   d G|  Gd GHt  j   | j   t  j   d G|  Gd GHt  j   t  j   t j |   t  j   | j   | j   | j   d  S(   NR   t   randomizingt   sortingi    s   entering barriers   leaving barrier(   R>   R   R   R"   RD   RT   R   R&   RG   R@   RU   R!   R;   RH   R%   (   R<   RI   t   bart   doneRL   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   _run_one_sort  s4    
 
	

  




 


 

  


c          C   sX  d d  l  }  |  j a d a t j   a t j   a t j   a g  a d } g  } x/ t	 |  D]! } | j
 t	 | d d   q^ Wt |  } t   } x+ t	 |  D] } t t | | | |  q W| j   d GHt r t d t f  n  xW t	 |  D]I } | | } t |  | d d k r9t d | d	 f  n  t |  q Wd
 Gt Gd GHd  S(   Nii    i   i   i
   s*   all threads done, and checking results ...s   threads still alive at ends   length of arrays
   screwed ups   test passed!s   threads created in all(   t   randomRS   R=   R   R   R<   R>   RR   R;   RF   R?   R   R"   RD   RZ   R   R   R@   RU   (   R[   t   NSORTSt   arraysRO   RX   RL   RI   (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   test7  s2    		

t   __main__(    (    (    (    (    (   R   R    R   R"   R)   R/   RD   RG   RT   RU   RZ   R^   R   (    (    (    s)   /usr/lib64/python2.7/Demo/threads/sync.pyt   <module>  s   TE			
			!