Using the ATTACH macro

Figure 1 illustrates the concept of performing an OS ATTACH to a C, C++, nonmultitasking PL/I, or COBOL program, and thus establishing a separate Language Environment runtime environment. For each ATTACH to a Language Environment-conforming routine, another Language Environment runtime environment is added to the MVS™ address space. In COBOL, this is called multitasking; COBOL RES multitasking is supported only when all of the COBOL programs are compiled with Enterprise COBOL for z/OS, COBOL for OS/390 & VM, COBOL for MVS & VM, or COBOL/370 (not with OS/VS COBOL or VS COBOL II).

Figure 1. Issuing an ATTACH to Language Environment-conforming routines
A root HLL routine is created when subtasks in an HLL are attached to an assembler routine.

When running with POSIX(ON), use the POSIX function pthread_create in place of OS ATTACH to create a new thread.

Currently, each Language Environment environment supports one process. Within the process each enclave supports a single thread.

To make best use of the ATTACH macro, you need to be aware of:
  • Whether you are using POSIX(ON) in a multithread environment. You must not use the ATTACH macro in this case. If you are running a PL/I multitasking application, you cannot use the ATTACH macro.
  • Whether the Language Environment environments share any resources.
  • The MVS affinity aspects of each routine. For example, if you OPEN a file in one TCB, you must CLOSE it in the same TCB.
  • The concurrency aspects of each routine. For example, you must ensure that two routines do not attempt to make contradictory or destructive changes to a data base.
  • The termination order of all routines, particularly those in a new Language Environment environment.
  • The compiler options and link-edit options when using COBOL.