ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/proc/self/root/usr/lib64/python2.7/Demo/threads/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/proc/self/root/usr/lib64/python2.7/Demo/threads/sync.pyc

�
��^c@s�ddlZddd��YZddd��YZddd��YZddd	��YZd
dd��YZd�Zd
�Zd�Zd�Z	d�Z
d�Zedkr�e�ndS(i����Nt	conditioncBsDeZdd�Zd�Zd�Zd�Zd�Zdd�ZRS(cCs�|dkrtj�|_n3t|d�rHt|d�rH||_n	td�tj�|_|jj�tj�|_d|_	d|_
d|_d|_d|_
dS(Ntacquiretreleases.condition constructor requires a lock argumenti(tNonetthreadt
allocate_locktmutexthasattrt	TypeErrortcheckoutRtidlocktidtwaitingtpendingt	toreleaset	releasing(tselftlock((s)/usr/lib64/python2.7/Demo/threads/sync.pyt__init__s	
				cCs|jj�dS(N(RR(R((s)/usr/lib64/python2.7/Demo/threads/sync.pyR*scCs|jj�dS(N(RR(R((s)/usr/lib64/python2.7/Demo/threads/sync.pyR-scCs3|j|j|j}}}|j�s5td�n|j�|j}|jd|_|j�|j�x?|j�|j�||jkr�Pn|j�|j�qoW|j	d|_	|j
d|_
|j
r�|j�n7d|_|j	|jko
dknrd|_n|j�|j�dS(Ns1condition must be .acquire'd when .wait() invokedii(RR	R
tlockedt
ValueErrorRRR
RRRR(RRR	R
tmyid((s)/usr/lib64/python2.7/Demo/threads/sync.pytwait0s2	
	




	
	"
cCs|jd�dS(Ni(t	broadcast(R((s)/usr/lib64/python2.7/Demo/threads/sync.pytsignalNsi����cCs�|dkrtd|f�n|dkr/dS|jj�|jrt|j|j|_d|_|jd|_n|dkr�|j|_nt|j|j|�|_|jr�|jr�d|_|j	j
�n|jj
�dS(Ni����s.broadcast called with num %rii(RR
RR
RRRtminRR	R(Rtnum((s)/usr/lib64/python2.7/Demo/threads/sync.pyRQs"
				N(	t__name__t
__module__RRRRRRR(((s)/usr/lib64/python2.7/Demo/threads/sync.pyRs				tbarriercBseZd�Zd�ZRS(cCs"||_||_t�|_dS(N(tnttogoRtfull(RR((s)/usr/lib64/python2.7/Demo/threads/sync.pyRfs		cCs]|j}|j�|jd|_|jr9|j�n|j|_|j�|j�dS(Ni(R RRRRRR(RR ((s)/usr/lib64/python2.7/Demo/threads/sync.pytenterks	
	

(RRRR!(((s)/usr/lib64/python2.7/Demo/threads/sync.pyRes	teventcBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCsd|_t�|_dS(Ni(tstateRtposted(R((s)/usr/lib64/python2.7/Demo/threads/sync.pyRws	cCs4|jj�d|_|jj�|jj�dS(Ni(R$RR#RR(R((s)/usr/lib64/python2.7/Demo/threads/sync.pytpost{s
	
cCs'|jj�d|_|jj�dS(Ni(R$RR#R(R((s)/usr/lib64/python2.7/Demo/threads/sync.pytclear�s
	cCs'|jj�|j}|jj�|S(N(R$RR#R(Rtanswer((s)/usr/lib64/python2.7/Demo/threads/sync.pyt	is_posted�s
	
cCs7|jj�|js&|jj�n|jj�dS(N(R$RR#RR(R((s)/usr/lib64/python2.7/Demo/threads/sync.pyR�s
	(RRRR%R&R(R(((s)/usr/lib64/python2.7/Demo/threads/sync.pyR"vs
				t	semaphorecBs&eZdd�Zd�Zd�ZRS(icCs>|dkrtd|�n||_||_t�|_dS(Nis semaphore count %d; must be >= 1(RtcounttmaxcountRtnonzero(RR*((s)/usr/lib64/python2.7/Demo/threads/sync.pyR�s
		cCsQ|jj�x |jdkr/|jj�qW|jd|_|jj�dS(Nii(R,RR*RR(R((s)/usr/lib64/python2.7/Demo/threads/sync.pytp�s

cCs`|jj�|j|jkr2td|j�n|jd|_|jj�|jj�dS(Ns:.v() tried to raise semaphore count above initial value %ri(R,RR*R+RRR(R((s)/usr/lib64/python2.7/Demo/threads/sync.pytv�s


(RRRR-R.(((s)/usr/lib64/python2.7/Demo/threads/sync.pyR)�s	tmrswcBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cCsRtj�|_d|_d|_d|_t|j�|_t|j�|_dS(Ni(	RRtrwOKtnrtnwtwritingRtreadOKtwriteOK(R((s)/usr/lib64/python2.7/Demo/threads/sync.pyR�s			cCsK|jj�x|jr)|jj�qW|jd|_|jj�dS(Ni(R0RR2R4RR1R(R((s)/usr/lib64/python2.7/Demo/threads/sync.pytread_in�s

cCsh|jj�|jdkr(td�n|jd|_|jdkrW|jj�n|jj�dS(Nis,.read_out() invoked without an active readeri(R0RR1RR5RR(R((s)/usr/lib64/python2.7/Demo/threads/sync.pytread_out�s
	cCs]|jj�|jd|_x#|js2|jrB|jj�q Wd|_|jj�dS(Ni(R0RR2R3R1R5RR(R((s)/usr/lib64/python2.7/Demo/threads/sync.pytwrite_in�s
	cCsr|jj�|js"td�nd|_|jd|_|jrT|jj�n
|jj�|jj	�dS(Ns-.write_out() invoked without an active writerii(
R0RR3RR2R5RR4RR(R((s)/usr/lib64/python2.7/Demo/threads/sync.pyt	write_out�s
				
cCsu|jj�|js"td�nd|_|jd|_|jd|_|jsd|jj�n|jj�dS(Ns1.write_to_read() invoked without an active writerii(	R0RR3RR2R1R4RR(R((s)/usr/lib64/python2.7/Demo/threads/sync.pyt
write_to_read�s
				(RRRR6R7R8R9R:(((s)/usr/lib64/python2.7/Demo/threads/sync.pyR/�s			
		
cGsytj�td}atj�tj�tj|�dG|GdGtt�GdGHtj�tj	||f|�dS(Nisstarting threads--talive(
ttidRtTIDRtioR;tappendtlenRtstart_new_thread(tfunctargsR((s)/usr/lib64/python2.7/Demo/threads/sync.pyt_new_thread�s




c
CsWtj�dG|GdG|G|GHtj�||dkr||}|d}xQt||�D]@}|||kr]||||||<||<|d}q]q]W||d|||<||d<t�}t�}	tt|||d|�tt||||	�|j�|	j�ntj�dG|GdGHtj	|�tj�|j
�dS(NRtqsortis
qsort done(R>RRtrangeR"RDt_qsortRR;tremoveR%(
R<tatltrtfinishedtpivottjtitl_subarray_sortedtr_subarray_sorted((s)/usr/lib64/python2.7/Demo/threads/sync.pyRG�s,



!		





cCs�tj�dG|GdGHtj�x]tdt|��D]F}tj�td|�}tj�||||||<||<q7Wtj�dG|GdGHtj|�tj�|j	�dS(NRsrandomizing arrayiisrandomizing done(
R>RRRFR@twhtrandintR;RHR%(R<RIRLRORN((s)/usr/lib64/python2.7/Demo/threads/sync.pyt
_randarrays




!



cCs.|tt|��kr*td|f�ndS(Nsa not sorted(RFR@R(RI((s)/usr/lib64/python2.7/Demo/threads/sync.pyt_check_sortscCs6tj�dG|GdG|GHtj�t�}tt||�|j�tj�dG|GdG|GHtj�|j�tt|dt	|�|�|j�t
|�tj�dG|GdGHtj�|j�tj�dG|GdGHtj�tj�tj
|�tj�|j�|j�|j�dS(NRtrandomizingtsortingisentering barriersleaving barrier(R>RRR"RDRTRR&RGR@RUR!R;RHR%(R<RItbartdoneRL((s)/usr/lib64/python2.7/Demo/threads/sync.pyt
_run_one_sorts4

	

















cCsXddl}|jadatj�atj�atj�agad}g}x/t	|�D]!}|j
t	|dd��q^Wt|�}t�}x+t	|�D]}t
t||||�q�W|j�dGHtr�tdtf�nxWt	|�D]I}||}t|�|ddkr9td|d	f�nt|�q�Wd
GtGdGHdS(Ni����iiii
s*all threads done, and checking results ...sthreads still alive at endslength of arrays
screwed upstest passed!sthreads created in all(trandomRSR=RRR<R>RRR;RFR?RR"RDRZRRR@RU(R[tNSORTStarraysRORXRLRI((s)/usr/lib64/python2.7/Demo/threads/sync.pyttest7s2		

t__main__((((((
RRRR"R)R/RDRGRTRURZR^R(((s)/usr/lib64/python2.7/Demo/threads/sync.pyt<module>sTE			
			!

Zerion Mini Shell 1.0