>>While GETMAIN does not immediately associate real storage, FREEMAIN
>>does disassociate and free any associated real storage and all slots
>>on page data sets if any of the pages have been paged out.
>
>I guess only those complete pages will be released?  
>Like what PGRLSE does.

My fault. This was not precise enough. You are correct in that only
completely free pages will be released.


>I used to think that VSM will defer the 'release' of the FREEMAINed 
>area so it can re-use the same area to satisfy subsequent GETMAINs.  
>Just my imagination :)

Ok, I thought I'll have to dig into a bit more sooner or later.

VSM manages virtual storage in 8 byte units, i.e. GETMAIN and FREEMAIN
are done in 8 byte increments. When you request some x bytes storage, 
GETMAIN will round up to the next 8 byte boundary, say x+. It will when 
search its inventory of allocated, i.e. GETMAINed storage to see
if there is a 4KB area (a page) where not all of the 4KB are allocated.
If it finds one and the free area within that page is at least x+ bytes,
then it will use that page and assign that address to your request.
If it does not find a free area large enough, it will look for the next
4KB are (page) of unallocate storage, allocate your x+ bytes from it
and puts the remaing bytes on the "free bytes list".

If you later FREEMAIN those x bytes, FREEMAIN will round up so the x 
becomes x+ again. It will but those x+ bytes to the "free bytes list",
so that storage could be used for another GETMAIN request *unless*
these were the last allocated bytes in the whole page (4KB). If the 
latter was the case FREEMAIN will release the real/aux storagea and
put the page back on the unallocated storage list.


This mechanism of sharing a single page for multiple GETMAIN request
is the reason you may or may not abend with a S0C4 if you try to 
access storage that you did not GETMAIN. You might end up accessing
some bytes within the same 4KB area as your allocated storage. That's
the bad situation, your program does not immediately abend but might
behave strangely late on. Storage overlays are very difficult to 
debug in some sitiations.


-- 
Peter Hunkeler
Credit Suisse

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to