Of course it was reentrant, but was it good form? I prefer to protect code against wild stores by marking it as r/o.
-- Shmuel (Seymour J.) Metz http://mason.gmu.edu/~smetz3 ________________________________________ From: IBM Mainframe Discussion List <[email protected]> on behalf of John McKown <[email protected]> Sent: Tuesday, November 26, 2019 3:32 PM To: [email protected] Subject: Re: WTO On Tue, Nov 26, 2019 at 1:21 PM Seymour J Metz <[email protected]> wrote: > What makes your program non-reentrant is failing to serialize shared data. > Long ago in a galaxy far away IBM actually shipped reentrant code that > modified itself; AFAIK they have cleaned up that abomination. > I agree that it's an abomination. But I have done it for a shared subroutine in a multitasking system. It was reentrant. What was modified was a 4 byte address. The code looked to see if the area was zero. If it was, I would do a GETMAIN. I would then update the address area using a CS to serialize the update. If the CS "succeeded", I would build a R/O table in that area. If the CS "failed", I would do a FREEMAIN of the storage. After this, I picked up the address and used it. This is reentrant according to the defination in Wikipedia: https://secure-web.cisco.com/1jsyGkFIj1WTeQ3KJFFZTdshHzHkTsH523_JLLN5q0_8zRvH5fDyxv6HpWDuG1ujz5M7NbyZLHHNNeBOxGyv06V0sdWDShL1sPaXH1ydr99wn9PTrvn8mQ371WstVbYW9PCG2qbfELdMura-qgBInB-IB-0MFntpaaeNNl-bzxuM984GbqsE_ddL1YhbrCgWQubkAMTjEccRf7KB7Q2KwjegMWw1XXJHCrcm4TL_cAMn8vn05YH1ziUeI57MUUZdjlabjreLj_0JG6nWfx-ye-qofzxhB_F3FgEQ-XjO56fQK_SzyF2LiKwEX4wsyo5ysZCu_vh7YWV2-N1K5ebEWMB0I9HfucI47A7MuIAZ005t8G7XOzjLBJl-nGalQLYL-Wc-_7_HKVqSJmz9v6fmKpmTWX7RL5TQyHeMbKnZe5NoKnIcLsmyhUUHUeWo7pX9B/https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FReentrancy_%28computing%29 ==== In computing <https://secure-web.cisco.com/1ZjmEMfGLtGLhHBYNlo3NQbuC9Kx08pOL_xYHK6N6lJTlNhiV7lQeJR9QeHa0xGdpxHX6Ex0Ag42sOV5Bk3UTsfslTCOZTASuDy-2thiEdgjD2MkmVQfUni6DRMRPp1ajS_3i-yhiqpGuizH5X_DLH853XbTQb6CTdSHxKCtRqUkE9Zbswu6ckP6-Px78S05zPg10CJxWwbx35r44jLaAcjkKOJhzCbsWBB4V836cvHp4EOtCJ3cJYWmxwo0rXpkkYBfZdRd-wqFW-X1jaRc-Rc7h3hweFnBhNLPc-8pfHGONgT8ZhUDgyk2Tc_vJ3hkywO6shGbHHuBDV1Bqhv-GPH_yNe8nJgjkWNz94iSmDKi2mw7cOX7zfEL8KbTI-6nWowDe9m3skZtsBw2jdErhzd-jaC4hxTzzVydZmr3dimNQ8Fa_ez3WUPuY7Rz25ged/https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FComputing>, a computer program <https://secure-web.cisco.com/1lGKb3w6sSwErv4GxKTE3yNh7nP14WN6hR6o-nyDb5ptekbmJbTTDM_lc4VWcup07fzCP-TO8C8OaV-5LRcoCkSyp9qq2SHXP14n35RnxMnVl_6YJWHCUhEnKMl_sCts3arkV7nMwQAundtdNMh1zFJ_sXoi7X6lAevvz1FOLILU-IJs4tXfIGHnxxVl5_wq4N0t6AeDiNwLcO8-1jSzHF_sROWG9Pw6caEuInKeyCOVfZ1bfCbWSfabH_RO6aIoaFSOMqSPRXuXMDxNfpzSUYe9K65PakzlmZfUM4XxoNIr5AUX4BYuS3jYi3MBD2H4ASLprEafCH_YZ31B3YUp2uMOIPyGaTXoKByMDtC17bGlmhcP8QJTW0da25CykpLgrlRm_yQgIV51HS7ObGs57qiRHhki3d7v1-waON8TYwfcU8nt8R0I39rrYj2EYtVzp/https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FComputer_program> or subroutine <https://secure-web.cisco.com/1LvShaQGJ5Haugx-x0ddU99Ov41vSARE-vQjGXNeQdokAnTPEJkafz5GdzC8YuSs1rIrvhNAAZN9iYRo3WZJimf9UpPju3fxLV5pcbWgHFj_YLSP26nDMlOcht_WXxyRrA1yBnUjefDkSm04JcoNGtkYuv44ce2b7YDAOSYCRSToxAR2boXUFns-cGsY_EDlhkv0nnbDT3BJG6qLpO_efdudqjSAyGX47WCDl8u7sdFfp6iZWA709x-05hYAaNiJ6wPKa20tgFKSLod7PWSxoZCukCAaW2iWDm9U-AQY9fdOob-tybILD-FlqDmJunYWU8mzxSaXyl2oybsTLEs-RvtTcg1_eRIvT9vZp-Ryfnh6X601VNm518qYfchbPk7-vL3jNp1ffp89tzh906FnFCLgDwWaLvGC5triIFwAyVtooKrJKQ8H13oj5ZRBNECjB/https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSubroutine> is called *reentrant* if multiple invocations can safely run concurrently. The concept applies even on a single processor system, where a reentrant procedure can be interrupted in the middle of its execution and then safely be called again ("re-entered") before its previous invocations complete execution. The interruption could be caused by an internal action such as a jump or call, or by an external action such as an interrupt <https://secure-web.cisco.com/1MpbMjgU5e_i-f3Hi_xFBU9ZNtHvnfaeiUOezyUKDEeLcA3ADsEx_zvEQkY5vIDYkQpZfq2sdiBrndsJyZEsyWWHb77RC2rUZ_PIMUbYBeNJ4P1H_Pi7oY5WelOVITBvve7ga-D-cLP3QG8Ux_jemww42LHrzZGaaEiqGylQme0oH11IhkELn57-wDDTvIdYfHj8-D8SPZtotz4sf0lfp59BZyKX-tzI55fC3iK0Yo9m9On5k62AZJVyH12Z453nnht8QBWUOpyYeSN1sdReLk8R1UX_evlWpY8Zx9obM1jegQcqG3vpoScmCetOIvkJv6EO3ftIOHnBglgVhz88u6u4NUg1N2gJZZzlp6IlO53Y0VfFw9KstB6w3N0mVn3RIkspRFQ9Hq_TDIXujwdg6Jp6wAWAb5wlhVVIJTy_v5MaZw-0zP3jjPA7BgOXxFjM7/https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FInterrupt> or signal <https://secure-web.cisco.com/1riRl2wbuaXCOxFX40HwfmYL_ad8twHwqnhuvbmK8v_Uv3h8Xe2Y3TZ7vyA8lyD0e0dpFWGfY3yEAOCGHzyrFd3lzlMeUzVKUA49JBg84UJGNokenz3M7oyjwuKu37PHaHzIzf51VrCnJdP1lzM4qxds2Lf0eW0WBhFKppuMRxCUogkZbtHJRTsJNZPmXuOg7QIBAKdjH-sWDE7VGG09lGfUHR0YvPz7Wl7hnRbAX1YIaeCSEvEQwhf5cx_Xe0gA15ilrCAM_tzh5AtadlscOijNEzjgVDyjOfJ-2KHuiqK19I-K8Bexkq6FE2qY-FqcEP0zcI2XwOFqwzxrJaKGti3sxcTI5WOPnzOMMlIza9PvfqVreQE6c4OGsSfFhlpnaP8UJyOGXsY96Oq8wHsFptm0MsslV5KN_vb_e_k2esAHH01wza0-DYOfI-ce3nkb6/https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSignal_%28computing%29>. The previous invocations may resume correct execution before the reentered invocation completes, unlike recursion <https://secure-web.cisco.com/1Jx6KeyYh-lnLfIqW2ztkS9HMN7iw5NjZKZP6OwJiOyxzQolVRXWIRxYQ0Fq7AqI_Sd-fcbayhkEODYobY7j2rnFSp1ERcevwwHd1ZzcRxfaRx6ydtrollASwbf9vfmehFq6pVsuOMntD4-AK2lxd444mYi7zqk-QSrwXAPA8XEYNEI8z94P9PxJcus0leOBDsUdnHtudsxegJnGU5nZ0enX_bjxDtV7_KarnZc0xEFOfr9-os7afAQBs93ZXrcxRjbENiJVIBuwYzX38Eu3eazXx0XjFEXrvmSa2HMXFwOugBbWcL0JUUCeht7P_ruewJWIChht5QZZ11dleNFq8tZJap1cxyDSDRp7op_BK4QZSTDwPT2tU9WT3RPkSdIxAnusmcLfQgzLEU-GqW67DqHeI0QMg_0JHHUTx1omaGrtUz5E9uTqvXoo8fFgtaicj/https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FRecursion_%28computer_science%29>, where the previous invocations may only resume correct execution once the reentered invocation completes. ==== Of course, in the latest z/OS code marked RENT (or is it REFR?) I think is loaded into key 0 storage and my code will fail, just like it does if it's loaded into LPA. I know of vendors in the past who demanded that their code be loaded into MLPA to avoid the "no store here". I have seen other code actually go key 0, change the protection on an LPA page to R/W, updated it, then change the protection back to R/O. All of the above is poor coding in today's environment. Today, I would use some some of Name/Token to "anchor" a data area. > > In the case of WTO, use of MF=L in the CSECT does not keep the code from > being reentrant if, as you describe later, the only use made of it is to > initialize dynamic storage. Used that way there are no shared data, hence > no need serialize. > > > -- > Shmuel (Seymour J.) Metz > http://mason.gmu.edu/~smetz3 > > send email to [email protected] with the message: INFO IBM-MAIN > -- People in sleeping bags are the soft tacos of the bear world. Maranatha! <>< John McKown ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
