This provides some synchronization between multiple copies of jkeyauto. For example you may run 100 versions of jkeyauto to simulate 100 users. Once you have got to an initial part of the application, you want jkeyauto to suspend until you are ready to continue. This means all instances of the application will start at the same point - there won't be any timing issues because some are running the application, others are still at the login prompt, others in the login program and so on.
Similar functionality can be executed using the -S option to jkeyauto. Therefore you can have your scripts configured so that they wait on a sync. signal and then an operator starts them all off from the command line.
SYNC LOCK|UNLOCK|TEST|WAIT expression {FOR expression_for} {SETTING variable_setting}
LOCK shows that lock number "expression" will be locked. No check is made on whether it is already locked or not, or if by the same instance of jkeyauto or not. The lock always works.
UNLOCK shows to unlock the lock number given by "expression". No check is made that the lock is already locked or that this instance of jkeyauto is the lock owner.
TEST allows you to see if lock number expression is set or not.
WAIT allows you to wait until lock number expression becomes unlocked.
expression_for allows you to add a timeout clause when the "SYNC WAIT" is used. Without this, then the SYNC will wait forever until the lock is unlocked. A value of 0 shows to return immediately.
variable_setting can be used to show why the SYNC statement returned. It is most useful in association with the WAIT operand but can be used to check for fatal errors in the other statements. It is set differently according to the type of lock.
LOCK | 0 shows the lock was taken. Any other value is the error number of a fatal error. |
UNLOCK | 0 shows the lock was unlocked. Any other value is the error number of a fatal error. |
TEST | 0 shows the requested lock is currently unlocked. 1 shows the requested lock is currently locked. |
WAIT | 0 shows the lock is unlocked or became unlocked. 1 shows the operation timed out. Any other value is the error number of a fatal error. |
SYNC LOCK 0 ;* Ensure lock 0 is locked
again: SYNC WAIT 0 FOR 2 SETTING rc
IF rc EQ 1 THEN PRINT "Waiting for sync . . ." ; goto again
IF rc NE 0 THEN PRINT "Fatal error" ; STOP
PRINT "Benchmark now begins !!!!"
JKEYAUTO