Sunteți pe pagina 1din 33

MULTI THREADED

ROUTINES

TEMENOS EDUCATION CENTRE

Warning: This document, is protected by copyright law and international treaties. No part of this
document may be reproduced or transmitted in any form or by any means, electronic or mechanical,
for any purpose, without the express written permission of TEMENOS Holdings NV Unauthorized
reproduction or distribution of this presentation or any portion of it, may result in severe civil and
criminal penalties, and will be prosecuted to the maximum Copyright © 2004under
extent possible TEMENOS HOLDINGS
applicable law.” NV
Information in this document is subject to change without notice.

Copyright © 2005 TEMENOS HOLDINGS NV


Agenda

‰ Introduction to multi threading

‰ Working of multi threaded routines

‰ Steps to create and attach a multi threaded routine to the


BATCH application

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 2


Multi-threading

‰ When a “single” process can be executed by more than one


processor, the process is said to be ‘multi-threaded’

‰ A ‘thread’ is the “smallest independent executable unit” of a


“process”

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 3


Single threaded VS Multithreaded Routines

AC.DISP – SINGLE THREADED AC.DISP - MULTITHREADED


• Display Account Ids and respective working balances
FN.AC = ‘F.ACCOUNT’ AC.DISP.LOAD
Initialise all variables
F.AC = ‘’
R.AC = ‘’

Open
CALL necessary
OPF(FN.AC,F.AC) files
SEL.CMD=“SELECT “:FN.AC
CALL
Select the ids
EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.REC,
AC.DISP.SELECT
RET.CODE)

LOOP
REMOVE Y.AC.ID FROM SEL.LIST SETTING POS
WHILE Y.AC.ID:POS How do we share
Process each ID variables across
CALL F.READ(FN.AC,Y.AC.ID,R.AC,F.AC,Y.ERR)
CRT Y.AC.ID:R.AC<WORKING.BALANCE>
AC.DISP(ID) routines?

REPEAT

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 4


Creating Common Variables

‰ Create an insert file and define the variables as common


variables
– Like I_COMMON, I_EQUATE etc

jsh…>JED TRG.BP I_AC.DISP.COMMON


COM /TRGCOMMON/ FN.AC,F.AC

‰ Include this file in all the 3 routines


– LOAD routine
– SELECT routine
– PROCESSING routine

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 5


Execution Of Multithreaded Routines

Load Routine Load Routine Load Routine

Select Routine

FBNK.JOB.LIST.<3>

Processing Routine Processing Routine Processing Routine

tSA 2 tSA 3 tSA 4

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 6


Creating The Load Routine

SUBROUTINE AC.DISP.LOAD
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_AC.DISP.COMMON
FN.AC = ‘F.ACCOUNT’
F.AC = ‘’
CALL OPF(FN.AC,F.AC)
RETURN
END

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 7


Creating The Select Routine

SUBROUTINE AC.DISPL.SELECT
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_AC.DISP.COMMON
SEL.CMD = “SELECT “:FN.AC
CALL EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.REC,RET.CODE)
CALL BATCH.BUILD.LIST(‘’,SEL.LIST)
RETURN
END

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 8


Creating The Processing Routine

SUBROUTINE AC.DISP (AC.ID)


$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.ACCOUNT
$INSERT I_AC.DISP.COMMON
CALL F.READ(FN.AC,AC.ID,R.AC.REC,F.AC,AC.ERR)
CRT R.AC.REC<AC.WORKING.BALANCE>
RETURN
END

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 9


PGM.FILE Entry

Must be left blank or


@BATCH.JOB.CONTROL
must be specified.

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 10


BATCH Entry

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 11


COB And Multithreaded Routines
tSA
tSA1(TSM)
tSAtSA 2 tSAtSA 3

Am I TSM Am I TSM

S.JOB.RUN S.JOB.RUN

EB.SORT.BATCH EB.SORT.BATCH

LD1,LD2,FX1,FX2,SC1,SC2 LD1,LD2,FX1,FX2,SC1,SC2

LD.EOD_LD1_BATCH.JOB.CONTROL_ _GB0010001_20040101
BNK/LD.EOD A001 : LD1,LD2
Sort all the
BATCH records BNK/SC.EOD A200 : SC1,SC2
in the order of
Batch Stage BNK/FX.EOD A100 : FX1,FX2

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 12


Execution Of COB Routines
tSA 2 tSA 3

LD1 LD2,FX1,FX2,SC1,SC2
LD1,,LD2,FX1,FX2,SC1,SC2 BtRec LD1
LD1,LD2,FX1,FX2,SC1,SC2
,LD2,FX1,FX2,SC1,SC2 BtRc

BtUpd BATCH BtUpd


BtUpd2 BNK/LD.EOD BtUpd2

LD1.LOAD LD1.LOAD
BATCH .STATUS BtSt

BNK/LD.EOD-LD1 BtSt
LD1.SELECT

Delete
Update
record
F.LOCKING
in F.LOCKING
like

UpdateBATCH.STATUS
Update BATCH.STATUS BtSt1 BtSt Read F.LOCKING and obtain LIST file Lk

1 LD1FMLD2
LD2
111,2,3
3 5
2,,35
4 3
,,2,3 333,4,5
4,,55
,,4,5
2 LD3FMLD4
LD4

No more records
3 LD6
in the LIST file
LD5FMLD6

4 LD8
LD7FMLD8
Record
Recordnot
locked
found LD9FMLD10
LD1
LD5FMLD6
LD7FMLD8
LD1
LD10
LD6
LD8
(LD10)
(LD1)
Record not found. LD1FMLD2
LD3FMLD4
LD1LD4
LD2
(LD1)
Give
No
Nome
more
more
more
records
records
records 5 LD9FMLD10
LD10
Give me more records Give me more records
to process

LD1
LD1(LD10)
(LD5)
(LD6)
(LD7)
(LD8)
(LD1)
(LD9)
LD1 (LD1)
(LD2)
(LD3)
(LD4)

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 13


BATCH.JOB.CONTROL

Key program that controls the multi threading process in T24.

- splits the job into ‘multiple’ threads


- executes them simultaneously
- and thus makes optimum use of the available processors

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 14


Example 1

There is a LOCAL.REFERNCE field by name CHG.FLG in the


Account application. This field can hold any one of the following
values - ‘Y’ or ‘N’. If the balance of any savings account falls
below 5000, then this field is to be set to ‘Y’.

(This routine needs to be executed everyday. Check if this local


reference field already contains a value ‘Y’, if so, then no check
needs to be done to the balance of the account and the value
should remain as ‘Y’.)

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 15


Solution 1

Decide the name of the subroutine

TRG.EOD.RTN

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 16


Solution 1 – Step 1

Create a file by name I_TRG.EOD.RTN.COMMON

I_TRG.EOD.RTN.COMMON

COM /TRG/ FN.AC,


F.AC,
R.AC.REC,
Y.AC.ERR,
Y.AC.LIST,
NO.SEL,
SEL.ERR

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 17


Solution1 – Step 2

Create a file named TRG.EOD.RTN.LOAD that will open


all necessary files

SUBROUTINE TRG.EOD.RTN.LOAD
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_TRG.EOD.RTN.COMMON
FN.AC = 'F.ACCOUNT' ; F.AC = ''
CALL OPF(FN.AC,F.AC)
RETURN
END

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 18


Solution 1 – Step 3

Create a file by name TRG.EOD.RTN.SELECT that will


selects all the ids from the customer file.

SUBROUTINE TRG.EOD.RTN.SELECT
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_TRG.EOD.RTN.COMMON

SEL.CMD = "SELECT “:FN.AC:” WITH CHG.FLG NE ‘Y’ AND


CATEGORY = 6000 AND WORKING.BALANCE LT 5000"
CALL
EB.READLIST(SEL.CMD,Y.AC.LIST,'',NO.SEL,SEL.ERR)
CALL BATCH.BUILD.LIST(‘’,Y.AC.LIST)
RETURN
END

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 19


Solution 1 – Step 4

Create a subroutine called TRG.EOD.RTN that will


manipulate on the ids available in the TRG.EOD.RTN.LIST
file.

SUBROUTINE TRG.EOD.RTN(Y.AC.ID)
$INSERT I_TRG.EOD.RTN.COMMON
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.ACCOUNT
CALL F.READ(FN.AC,Y.AC.ID,R.AC.REC,F.AC,Y.AC.ERR)
R.AC.REC<AC.LOCAL.REF,2> = ‘Y’
CALL F.WRITE(FN.AC,Y.AC.ID,R.AC.REC)
RETURN
END

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 20


Solution 1 – Step 5

Make an entry in the PGM.FILE with the type as ‘B’.

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 21


Solution 1 – Step 6

Make an entry in the BATCH application

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 22


Summary

‰ When a single process can be executed by more than one


processor, the process is said to be multi-threaded

‰ BATCH.JOB.CONTROL is the T24 subroutine that makes multi


threading possible in T24

‰ The xxx.SELECT routine will prepare a key only file containing all
the ids which need to be processed by this job

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 23


Summary (Cont.)

‰ The xxx.LOAD subroutine performs any initialization required


‰ The xxx.COMMON is an insert file that holds all the variables
used by the job
‰ The xxx subroutine is the batch job itself with ONE argument
passed (the id to be processed).
‰ It is very important not to perform any initialization in this
program – this will be repeated THOUSANDS of times as the
routine is called for every passed id.

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 24


Workshop 1

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 25


BNK/LD.EOD – BATCH RECORD

Back

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 26


Batch Record Update

Back

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 27


F.LOCKING File

ID BNK/LD/EOD-LD1

Content FBNK.JB.LIST.2

Back

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 28


F.BATCH.STATUS FILE

BNK/LD.EOD-LD1

processing

Back

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 29


F.BATCH.STATUS FILE

BNK/LD.EOD-LD1

processing

Back

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 30


F.BATCH.STATUS FILE

BNK/LD.EOD-LD1

processing
processed

Back

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 31


F.BATCH.STATUS FILE

BNK/LD.EOD-LD1

processing
processed

Back

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 32


Batch Record Update

Back

T3ATT – R05 – 1.0 Copyright © 2005 TEMENOS HOLDINGS NV 33

S-ar putea să vă placă și