home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rxsem104.zip
/
rexxsem.txt
< prev
next >
Wrap
Text File
|
2000-08-17
|
8KB
|
206 lines
REXXSEM
=======
The Read-me
+-----------+
REXXSEM - WHY!?!?!?
-------------------
After years of using REXX and months trying to get multiline
support for my BBS in REXX, I got fed up. I wanted semaphore support -
both to interface with Squish (which uses 16-bit mutex semaphores) and
everything else (using 32-bit mutex semaphores which will be faster
under OS/2 2.0+). I wanted to prevent programs which were too dumb to
provide their own semaphoring from running simultaneously with each
other. And here's the rexx routines I came up with. If they help you,
I'd be happy to know. If there are some extentions you would like to
see, let me know as well. And if you would like to offer some example
rexx scripts, that would be great, too.
What REXXSEM does
-----------------
REXXSEM is a REXX-extention DLL. That is, it is a DLL that is
written to allow REXX scripts to call it. This works similar to the
REXXUTIL that come with OS/2's REXX.
The REXXUTIL were written to give basic access to some very
useful OS/2 API functions dealing with file systems, WPS, and other
areas. REXXSEM was written to give basic access to some other very
useful OS/2 APIs: the mutual-exclusion (mutex) semaphores.
REXXSEM's semaphores, then, work the same way as the OS/2 API
semaphore functions. This includes using OS/2's ability to block your
REXX script until the desired semaphore is available (to use zero CPU
cycles while waiting), priority-based scheduling (if a high-priority
program is waiting on your semaphore, you will get its priority until
you release the semaphore), and priority-based semaphore ordering (the
highest priority thread that is waiting for a semaphore will get it
next).
When to use REXXSEM
-------------------
The "old" (DOS?) way of finding out whether another script is
running is to look for a "semaphore" file. If it doesn't exist, create
it and continue. If it does exist, wait a second and look again in a
loop until it no longer exists. When you're done, delete the file.
This is tedious, error prone, and CPU (and disk!) intensive.
Every time you want to do this, you need to write your code out, and,
if you code like me, you'll forget something different each time,
ensuring a fun time debugging.
This is where other languages excel: they allow you to call the
OS's semaphores. Well, now you can do the same thing in REXX.
Actually, you could before if you have ObjectREXX which has
semaphoring functions built in. What I found is that ObjectREXX
couldn't perform at all on my old 486dx2/66. Since then, I haven't
switched back even though I have a faster machine. If you don't want
the overhead of ObjectREXX but want semaphores, this is the perfect
package.
What else?
----------
REXXSEM does not have to abort your script with some cryptic
"bad function call" message. If you use the SemReturnValidAlways
function to turn this feature on, all functions will always return
valid, but will provide an explanation of what the problem is. In
fact, these messages can be translated and used in whichever language
you want, if I can find a translator from English to your language.
Mind you, these messages can get a little long for a single
string, so there is a WordWrap function to wrap the words at whatever
width you want (defaulting to the current session's width). (This may
not work well in a PM REXX session - but you can specify a width to
use.)
Other neat features added were the ability to open Netscape
windows ... without unnecessarily starting new processes.
OpenNetscapeWindow will let you open a URL without starting new
processes - a method that is rapidly faster than just typing "start
netscape <url>", and consumes vastly less memory. You can specify
whether to use an existing (OLD) netscape window, or to have Netscape
create a new (NEW) window.
Of course, somewhere in there the REXXSEM dll must determine
whether or not netscape is running, so I externalized part of this as
well: ProcessIDsOf will tell you all process ID's of any given process
name(s). You can find out how many CMD sessions are running, even
their process ID's (which may come in handy for other purposes later
on, such as killing them). This method is faster than using pstat with
rxqueue and reading it line-by-line if you just need to know whether
the process exists or not. It uses some new APIs to do this which
preclude pre-Warp OS/2, and even preclude some fixpaks of Warp 3.
In 0.7, VIO-window-handling functions were added.
RxWinSetTitle will let you set the title of the current session.
In 1.0, priority-handling functions were added. You can now
query, and set, your priority, or the priority of any of your children
(if you're not blocked on them).
Is there anything missing? Have a favourite function that
you'd like to see in a REXX DLL? If you have it written in
VAC-compatable code, send it in and I'll try to get it in!
How to use REXXSEM
------------------
REXXSEM uses standard REXX methods: put the dll in your libpath
somewhere, and read the reference (rxsemref.htm)! We assume you know
how to use REXX. If not, find a book on REXX (there are many good
ones), and sit down and read. It's not a hard language. :-)
(<phew>, that was easy. :-)
REXXSEM licencing
-----------------
REXXSEM is distributed as licenced shareware. REXXSEM ("the
Program") is copyright 1997, 2000 by the author and all rights are
reserved.
Under this licence, you may:
1. use the Program in binary form only.
2. make copies of the original file you downloaded and distribute it,
provided that you transfer a copy of this licence to the other party.
You may NOT:
1. reverse assemble, reverse compile, or otherwise translate the
program.
2. distribute the Program, in whole or in part, with any shareware or
commercial application.
3. use your program key on more than one computer where they may be in
use on more than one computer at a time.
A separate licence is available for licensing with shareware and
commercial distribution.
The author expressly disclaims all liabilities arising from the
use of the Program, including, but not limited to, (i) third-party
claims against you, (ii) loss of, or damage to, your records or data,
(iii) economic consequential damages (including lost profits or
savings) or incidental damages, even if the author is informed of their
possibility.
THERE ARE NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
You may not sell, transfer, assign, or subcontract any of your
rights or obligations under this license. Any attempt to do so is void.
This license is governed by the laws of Ontario, Canada.
Registering REXXSEM
-------------------
There are a number of functions in REXXSEM marked "Registered".
These functions will only be unlocked by registering REXXSEM. While
the core functionality (the semaphore functions) will always work,
these extra functions are the incentive or reward for registering the
product.
To register the product, I only accept registrations through
BMTMicro. Go to https://secure.bmtmicro.com/order1476.html to get
directly to the order form. The price is currently $20 US.
REXXSEM Mailing list
--------------------
REXXSEM has a mailing list now. Send a note to
majormajor@tower.to.org with 'subscribe RxSem' in the body. I use
Peter Moylan's software exclusively here - Weasel and MajorMajor.
REXXSEM's author
----------------
Darin McBride - longtime OS/2 abuser, longertime sysop. Obviously he
enjoys causing himself headaches. If you have a cure for these
headaches, or just some general REXXSEM questions, you can contact him
as below:
EMail: dmcbride@tower.to.org (preferred)
d.mcbride@home.com
Web: http://tower.to.org/rexxsem
Fidonet: <arf, arf!>
Netmail: Darin McBride, 1:250/102
Echos: C_ECHO, C_PLUSPLUS, OS2PROG
(REXXSEM is only on-topic in OS2PROG and OS2REXX, although I
don't read OS2REXX)