Description of MTREXX
Download count: 24 this month, 5442 altogether.
Downloads for MTREXX:
VMARC archive: v-28K
CMS 9 had multitasking support added to it, including support for the use of REXX in multitasking applications. However there was one problem. A REXX exec itself could not create threads, nor could it be the main entry point for a thread. This package, MTREXX, attempts to remove these restrictions from REXX programmers.
The syntax is:
MTREXX Rexx_exec_name Rexx_exec_parameters
The REXX execs have a filetype of MTREXX. The MTREXX module provides a ThreadCreate function to the REXX execs that it runs. Using this a REXX exec can ThreadCreate other REXX execs. The remaining multitasking functions are available to the REXX programmer via the CSL function. The syntax for the ThreadCreate function is:
it returns two numbers. The first is the return code. If this number is zero, the second number is the thread id of the newly created thread. If the first number is non-zero the second number is the reason code for the error. The thread inherits the creator's priority and is in a new class of it's own.
I provide a number of example "applications". The first is
three REXX execs FRED, FRED1 and FRED2. FRED simply creates
two threads, one running FRED1 and the other running FRED2.
These threads loop 10 times yielding each time thru the loop.
To run it do:
The second example is a REXX variant of the C sample application from chapter 15 of SC24-5766, CMS Application Multitasking. What a difference a language makes! Coding this in REXX lets you concentrate on the multitasking piece rather than the vulgarities of the language. It also is three REXX execs. SAMPMAIN, SAMPTHD1 and SAMPTHD2. To run it do:
Note that the earlier release of MTREXX provided the sample application from SC24-5652 (this was the previous edition of the CMS Application Multitasking book). The sample application was revised for CMS 12 and my REXX code now matches the revised example.
The third example shows how to use REXX sockets with MTREXX. Once
again it is three REXX execs VMTIMED, DAYTIME and TIME. You require
RXSOCKET V3 (the one shipped with CMS starting with release 13)
and you *must* have APAR
VM61344 applied (yes, that's the right APAR number). It is a never
ending server, that provides timing information to requesters over
UDP and TCP sockets (if anyone writes the NTP piece please let me
know). To run it do:
I'm pretty excited about the availability of a thread aware REXX Sockets. This really opens up a bunch of possibilities for multithreaded applications in REXX. A redbook will be available shortly with more examples of multithreaded socket use from REXX.
I've coded this on CMS 10, but it should work fine on any release of CMS with MT support, 9 thru 14.
If you make use of this code for production applications, or make updates to MTREXX I'd like to hear from you. I welcome feedback and will try to help with problems/questions. Thanks ... Perry