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

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

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

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

РТА:

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

ИТП:

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

alg A20( ):

Zh7( );

Zh5( )

def A20(ccrt, hCycles):

hCycles.za20 = 0

hCycles.Zh(ccrt.techsys.head7)

hCycles.Zh(ccrt.techsys.head5)

hCycles.za20 = 1

alg A21( ):

Zh8( )

def A21(ccrt, hCycles):

hCycles.za21 = 0

hCycles.Zh(ccrt.techsys.head8)

hCycles.za21 = 1

alg A11( ):

Zh5( )

def A11(ccrt, hCycles):

hCycles.za11 = 0

hCycles.Zh(ccrt.techsys.head5)

hCycles.za11 = 1

alg A10( ):

Zh2( );

Fork(A20( ));

Zh4( );

Fork(A21( ));

Zh2( );

Join_&(A21( ));

Join_&(A20( ));

def A10(ccrt, hCycles):

hCycles.za10 = 0

hCycles.Zh(ccrt.techsys.head2)

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

hCycles.Zh(ccrt.techsys.head4)

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

hCycles.Zh(ccrt.techsys.head2)

while not hCycles.za21:

time.sleep(0.1)

while not hCycles.za20:

time.sleep(0.1)

hCycles.za10 = 1

alg A401( ):

Zh1( );

Fork(A10( ));

Fork(A11( ));

Zh3( );

Zh1( );

Join_&(A11( ));

Join_&(A10( ));

def eAxx1(ccrt, hCycles):

hCycles.Zh(ccrt.techsys.head1)

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

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

hCycles.Zh(ccrt.techsys.head3)

hCycles.Zh(ccrt.techsys.head1)

while not hCycles.za11:

time.sleep(0.1)

while not hCycles.za10:

time.sleep(0.1)

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

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

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

def A20(ccrt, hCycles):

hCycles.za20 = 0

hCycles.Zh(ccrt.techsys.head7)

hCycles.Zh(ccrt.techsys.head5)

hCycles.za20 = 1

def A21(ccrt, hCycles):

hCycles.za21 = 0

hCycles.Zh(ccrt.techsys.head8)

hCycles.za21 = 1

def A11(ccrt, hCycles):

hCycles.za11 = 0

hCycles.Zh(ccrt.techsys.head5)

hCycles.za11 = 1

def A10(ccrt, hCycles):

hCycles.za10 = 0

hCycles.Zh(ccrt.techsys.head2)

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

hCycles.Zh(ccrt.techsys.head4)

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

hCycles.Zh(ccrt.techsys.head2)

while not hCycles.za21:

time.sleep(0.1)

while not hCycles.za20:

time.sleep(0.1)

hCycles.za10 = 1

def eAxx1(ccrt, hCycles):

hCycles.Zh(ccrt.techsys.head1)

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

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

hCycles.Zh(ccrt.techsys.head3)

hCycles.Zh(ccrt.techsys.head1)

while not hCycles.za11:

time.sleep(0.1)

while not hCycles.za10:

time.sleep(0.1)

8

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