A program dynamically allocates a device. Once the device is successfully allocated, it is not eligible for deletion. After the device is allocated, the program finds the UCB associated with the device. Because the program has allocated the device, there is no need to pin it.
However, if the program passes the address to another program or unit of work, the passing program must pin the UCB. Then the passing program can pass the UCB address and the pin token to another unit of work (such as a task) for its use. For example, a program stores the UCB address in a commonly addressable storage location and posts another task. Before issuing the POST macro, the program must pin the UCB with the UCBPIN macro and specify the LASTING parameter, and then pass the UCB address and pin token to the task. The task must then unpin the UCB after it has finished using the UCB.
If the UCB had been pinned with UCBPIN LASTING by the first program before the POST macro was issued, the device could not have been deleted when the first program unallocated the device.