Others have given you good replies. I've been thinking about your question
and thought I would summarize and re-phrase what has been said. You are not
very specific in what your situation is, so let me offer three possible
problem scenarios, each with its own solution.

I. "I am doing something that is going to require a whole lot of processing,
like computing pi to a million digits. It occurs to me that I have been
processing for quite some time. I would like to be polite and give others a
chance."

Solution: Do nothing special. This is the magic of MVS and WLM. Assuming WLM
is set up properly, and you are in an appropriate WLM class, then when their
algorithms decide that someone else deserves to run, they will get to run,
and then after a while you will run again, all seamlessly and transparently,
with no effort on your part. (If that assumption is wrong, then you need to
fix that.)

II. "My code handles something that happens from time to time, like a
transaction coming in on the wire. There is no work to do at the moment but
there may be shortly."

Solutions: (a.) Look first at WAIT and POST. WAIT will let your task give up
the CPU until whatever process gives you work indicates that there is
something to do, with POST.

(b.) If you do not have control of the process that gives you work to do and
so cannot add a POST to it -- perhaps you are monitoring jobs in other
address spaces and watching for something to happen there -- then look at
STIMER WAIT. That will let you give up the CPU for a tenth of a second or
ten seconds or whatever is appropriate.

(c.) If there is plenty of work to do, but you need some resource that is
currently unavailable -- a file or a common buffer or something like that --
to be able to do it, then look at ENQ and DEQ. They will let you give up the
CPU until the process that is using the common resource relinquishes it.

In other words, there is no single magic "umm, I have nothing to do for a
little while; come back to me when I do" service available in MVS without
your specifying a little better what the condition is that will constitute
"something to do."
        
III. "Everything you say is well and good, but my code is running in an MVS
exit, or as an SRB, or holds locks, or something like that, which precludes
the use of WAIT and similar services." I think this is not likely your
situation but for completeness I will cover it.

Solution: yes, take a look at CALLDISP as others have suggested. It's not
the right solution if I. or II. is your situation, but if III. applies, then
yes, this is a possible answer to your question.

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
Behalf Of Thomas David Rivers
Sent: Thursday, October 17, 2019 8:54 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Best way for a task to give up the CPU and let other tasks run?

Does anyone happen to know the best way for a running task
to give up running and let another task run?

But - this isn't "give up" as in ending the task, just giving up
the CPU to allow another task to run and then returning to this
task.

Sorta like "I'm done for the moment if something else would like to run".

   - Thanks -
    - Dave R. -

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to