UHAP033@vaxb.rhbnc.ac.uk (08/10/89)
Hello all, I am currently working on an image processing simulation program that requires a single process on a transputer to determine how much CPU time it has had (but not that of any other processes in parallel with it) ie: PRI PAR PAR ... pass data down ... pass data up ... wait for a known time -- this it the problem bit My current process looks something like (slightly simplified): BOOL not.yet.finished: TIMER clock: INT pause.1,pause.2,elapsed.time: SEQ not.yet.finished:= TRUE clock ? pause.1 WHILE not.yet.finished SEQ clock ? pause.2 elapsed.time:= pause.2-pause.1 not.yet.finished:= (elapsed.time<required.delay) However, this doesn't do what I want - it keeps counting time even when the transputer is executing another process. Two possible alternatives came to mind: 1) Write a simple loop program, disassemble it and work out how long the loop would take. Then use something like INT required.iterations,dummy.variable: SEQ required.iterations:= required.delay*kludge.factor SEQ loop = 1 FOR required.iterations dummy.variable:= dummy.variable*1 -- time waster Unfortunately, I know nothing about transputer machine code, and so wouldn't know how to find out the time taken per iteration of the loop. 2) Since the clock's tick rate for a low-priority process is quite slow (64 microseconds according to the TDS book* page 60), it might be possible to count the ticks of the clock (the count being missed if the process is interrupted by a higher priority one), thus INT elapsed.time,tick.1,tick.2: BOOL not.yet.finished: TIMER clock: SEQ not.yet.finished:= TRUE elapsed.time:= 0 WHILE not.yet.finished SEQ clock ? tick.1 clock ? tick.2 WHILE tick.1=tick.2 clock ? tick.2 elapsed.time:= elapsed.time+64 -- microseconds not.yet.finished:= (elapsed.time<required.delay) But this is not elegant, and isn't very accurate either. Has anyone got any comments on these two schemes, or do they have a better one? Thanks for any help you can give Simon Barker * Transputer Development System, Prentice Hall, 1988, ISBN 0-13-928995-X -------------------------------------------------------------------------------- _______ __ __ / | | | / / Royal Holloway and Bedford New College / | | |/ / Machine Vision Group / /| /| | | / /__/ |/ |__| |____/ Simon Barker Phone: (0784) 439900 (UK) Department of Physics (+44) 784 439900 (international) Royal Holloway and Bedford New College JANET: UHAP033@UK.AC.RHBNC.VAXA or Egham Hill BARKER@UK.AC.RHBNC.PH.V1 Egham Surrey, TW20 0EX BITNET: UHAP033@VAXA.RHBNC.AC.UK or England BARKER@V1.PH.RHBNC.AC.UK