Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
7
Добавлен:
02.05.2014
Размер:
236.03 Кб
Скачать
      1. Многопоточная программная реализация алгоритма

          1. Реализация компонент алгоритма

Далее представлена многопоточная программная реализация заданных фрагментов исходного параллельного алгоритма.

Язык программирования: Питон (Python)

РТА:

Рабочий текст алгоритма

ИТП:

Исходный текст подпрограмм

alg A10( ):

Zh7( );

Zh4( )

def A10(ccrt, hCycles):

hCycles.za10 = 0

hCycles.Zh(ccrt.techsys.head7)

hCycles.Zh(ccrt.techsys.head4)

hCycles.za10 = 1

alg A11( ):

Zh3( );

Zh5( )

def A11(ccrt, hCycles):

hCycles.za11 = 0

hCycles.Zh(ccrt.techsys.head3)

hCycles.Zh(ccrt.techsys.head5)

hCycles.za11 = 1

alg A12( ):

Zh8( )

def A12(ccrt, hCycles):

hCycles.za12 = 0

hCycles.Zh(ccrt.techsys.head8)

hCycles.za12 = 1

alg A13( ):

Zh1( )

def A13(ccrt, hCycles):

hCycles.za13 = 0

hCycles.Zh(ccrt.techsys.head1)

hCycles.za13 = 1

alg A601( ):

Zh2( );

Fork(A10( ));

Fork(A11( ));

Fork(A12( ));

Fork(A13( ));

Zh0( );

Zh2( );

Join_&(A13( ));

Zh0( );

Join_&(A12( ));

Join_&(A11( ));

Join_&(A10( ));

def eAxx1(ccrt, hCycles):

hCycles.Zh(ccrt.techsys.head2)

thread.start_new(expSub.A10, (ccrt, hCycles, ))

thread.start_new(expSub.A11, (ccrt, hCycles, ))

thread.start_new(expSub.A12, (ccrt, hCycles, ))

thread.start_new(expSub.A13, (ccrt, hCycles, ))

hCycles.Zh(ccrt.techsys.head10)

hCycles.Zh(ccrt.techsys.head2)

while not hCycles.za13:

time.sleep(0.1)

hCycles.Zh(ccrt.techsys.head10)

while not hCycles.za12:

time.sleep(0.1)

while not hCycles.za11:

time.sleep(0.1)

while not hCycles.za10:

time.sleep(0.1)

          1. Исходный текст программной реализации

ВИ: Вертикальное исполнение

Первичное решение

def A10(ccrt, hCycles):

hCycles.za10 = 0

hCycles.Zh(ccrt.techsys.head7)

hCycles.Zh(ccrt.techsys.head4)

hCycles.za10 = 1

def A11(ccrt, hCycles):

hCycles.za11 = 0

hCycles.Zh(ccrt.techsys.head3)

hCycles.Zh(ccrt.techsys.head5)

hCycles.za11 = 1

def A12(ccrt, hCycles):

hCycles.za12 = 0

hCycles.Zh(ccrt.techsys.head8)

hCycles.za12 = 1

def A13(ccrt, hCycles):

hCycles.za13 = 0

hCycles.Zh(ccrt.techsys.head2)

hCycles.za13 = 1

def eAxx1(ccrt, hCycles):

hCycles.Zh(ccrt.techsys.head2)

thread.start_new(expSub.A10, (ccrt, hCycles, ))

thread.start_new(expSub.A11, (ccrt, hCycles, ))

thread.start_new(expSub.A12, (ccrt, hCycles, ))

thread.start_new(expSub.A13, (ccrt, hCycles, ))

hCycles.Zh(ccrt.techsys.head10)

hCycles.Zh(ccrt.techsys.head2)

while not hCycles.za13:

time.sleep(0.1)

hCycles.Zh(ccrt.techsys.head10)

while not hCycles.za12:

time.sleep(0.1)

while not hCycles.za11:

time.sleep(0.1)

while not hCycles.za10:

time.sleep(0.1)

8

Соседние файлы в папке Расчетно-графическая работа (3 части)1