Path: utzoo!mnetor!uunet!husc6!think!ames!oliveb!pyramid!voder!cullsj!jayz From: jayz@cullsj.UUCP (Jay Zorzy) Newsgroups: comp.os.vms Subject: Re: 2 C questions Message-ID: <282@cullsj.UUCP> Date: 13 Apr 88 00:42:15 GMT References: <281@cullsj.UUCP> Organization: Cullinet Software, San Jose, CA Lines: 38 From article <281@cullsj.UUCP>, by jayz@cullsj.UUCP (Jay Zorzy): > It depends on the size of the variables. Dynamic variables are allocated > from the stack, so if you've got huge arrays, VMS will obviously have more > work to do to allocate them on the stack. Another point to consider, is > that static variables are allocated during image activation in R/W, copy- > on-reference (CRF) sections. Depending on the frequency these sections > are accessed, you may have paging activity to consider. I've taken a lot of heat on this one. Yes, it's true that all that's required to expand the stack is a simple SUBL instruction to reset the stack pointer to a lower address in P1 space. Where you pay a penalty is when this address is beyond any previously allocated P1 space; the next instruction that attempts to access this address will incur an access violation. The access violation is then handled by an exception service routine which, if possible, must allocate additional virtual memory in P1 space. So there is some dynamic memory allocation overhead involved in some cases, particularly in recursive routines that have large local data segments. The difference is the memory is allocated during execution instead of image activation. By the way, if the aforementioned exception service routine fails to allocate the needed memory (insufficient PGFLQUO/VIRTUALPAGECNT/etc), then the access violation is passed on to user or system condition handlers. So an ACCVIO with a reason mask bit 0 set and virtual address in P1 space (i.e. 3FFFFFFF < VA < 80000000) is really an insufficient memory condition. Speaking of stacks, here's a common gotcha to watch out for: If you're issuing any asynchronous $QIOs (no wait, I/O completion handled by AST routine), make sure to declare your IOSB variables as static. Otherwise, once the calling routine returns, the stack is reset; an IOSB on the stack may now point to never-never land. Hope this information is useful... Jay Zorzy Cullinet Software San Jose, CA