Discussion:
[H390-MVS] ATTACH macro info
Mike Stramba mikestramba@gmail.com [H390-MVS]
2018-09-01 11:58:26 UTC
Permalink
When using the ATTACH Macro :

1) Is a LOAD macro required first for the "attach target" ?

2) If #1, would the target be named in a STEPLIB statement ?

I'm looking for example code, the only thing I've found so far is
"MODREP" in CBT #316

Mike
mikerayborn@gmail.com [H390-MVS]
2018-09-01 14:19:07 UTC
Permalink
Mike, no LOAD is required or desired. ATTACH will bring the module into storage, create the necessary control blocks, and begin execution under control of a sub task TCB.

The attached module needs to be found in the normal search order, job pack library, step library, system library, etc.

As for sample code, I typically do most coding in C, so here's a sample in C:

static int
attach(CTHDTASK *task)
{
unsigned work[16] = {0};

/* attach our subtask driver module.
** the task->tcb is created here if the attach was a success.
*/
__asm__(
"LA\t1,0(,%2)\n\t"
"ATTACH EP=CTHREAD,ECB=(%3),DPMOD=-1,SF=(E,(%4))\n\t"
"ST\t1,%0\n\t"
"ST\t15,%1"
: "=m"(task->tcb), "=m"(task->rc)
: "r"(task), "r"(&task->termecb), "r"(work) );

return task->rc;
}

Hopefully you get the basic idea. I'm sure others here can provide sample code in pure assembler.

--Mike Rayborn
Mike Rayborn mikerayborn@gmail.com [H390-MVS]
2018-09-01 14:11:39 UTC
Permalink
Mike, no LOAD is required or desired.  ATTACH will bring the module into
storage, create the necessary control blocks, and begin execution under
control of a sub task TCB.

The attached module needs to be found in the normal search order, job
pack library, step library, system library, etc.

As for sample code, I typically do most coding in C, so here's a sample
in C:

static int
attach(CTHDTASK *task)
{
    unsigned    work[16]    = {0};

    /* attach our subtask driver module.
    ** the task->tcb is created here if the attach was a success.
    */
    __asm__(
        "LA\t1,0(,%2)\n\t"
        "ATTACH EP=CTHREAD,ECB=(%3),DPMOD=-1,SF=(E,(%4))\n\t"
        "ST\t1,%0\n\t"
        "ST\t15,%1"
        : "=m"(task->tcb), "=m"(task->rc)
        : "r"(task), "r"(&task->termecb), "r"(work) );

    return task->rc;
}

Hopefully you get the basic idea.  I'm sure others here can provide
sample code in pure assembler.

--Mike Rayborn
Post by Mike Stramba ***@gmail.com [H390-MVS]
1) Is a LOAD macro required first for the "attach target" ?
2) If #1, would the target be named in a STEPLIB statement ?
I'm looking for example code, the only thing I've found so far is
"MODREP" in CBT #316
Mike
wably@sbcglobal.net [H390-MVS]
2018-09-01 12:11:16 UTC
Permalink
Mike,


There is no need to issue LOAD to bring in a module prior to using ATTACH. ATTACH will bring in the load module automatically and the resulting subtask will begin execution at the load module's entry point. The load module to be attached will be fetched from the STEPLIB concatenation unless you use other optional parameters on ATTACH to cause it to fetch from elsewhere.


In its simplest form, you can simply code this:


label ATTACH EP=modulename


The new subtask TCB address will be in GR1 upon return from the macro.


Regards,
Bob
johnjamesmain@gmail.com [H390-MVS]
2018-09-01 18:14:20 UTC
Permalink
On the other hand, you can indeed use LOAD and then use ATTACH if you want to (for example, if you want to leave the load module sitting there in the region when the task terminates, e.g. if it's a serially-reusable program that you want to use again later).


In that case you use the EPLOC= parameter as described in the Macros manual, instead of EP=.



HTH, JJ
'Shelby Beach' shelby.beach@comcast.net [H390-MVS]
2018-09-01 18:34:16 UTC
Permalink
Hi Mike,

And just to add to the innumerable options available, here's an ATTACH that
uses an entry point created by IDENTIFY. Although not a requirement, the
code to be attached just happened to be in a CSECT linked into the load
module (hence the VCON). It could, however be any code already available
some where in virtual storage.

L R1,=V(EXPTRACE) R1 = A(Trace routine)
IDENTIFY EP=EXPTRACE,ENTRY=(1) Add minor entry pt.

ATTACH EP=EXPTRACE,ECB=ECBTRACE,SHSPV=21
ST R1,TCBTRACE Save A(TCB) for DETACH.

Shelby



_____

From: H390-***@yahoogroups.com [mailto:H390-***@yahoogroups.com]
Sent: Saturday, September 01, 2018 11:14 AM
To: H390-***@yahoogroups.com
Subject: [H390-MVS] Re: ATTACH macro info






On the other hand, you can indeed use LOAD and then use ATTACH if you want
to (for example, if you want to leave the load module sitting there in the
region when the task terminates, e.g. if it's a serially-reusable program
that you want to use again later).

In that case you use the EPLOC= parameter as described in the Macros manual,
instead of EP=.


HTH, JJ

Loading...