Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!oliveb!pyramid!leadsv!laic!darin From: darin@laic.UUCP (Darin Johnson) Newsgroups: comp.os.vms Subject: Re: 2 C questions Message-ID: <203@laic.UUCP> Date: 8 Apr 88 01:42:52 GMT References: <12387779883.20.STEINBERGER@KL.SRI.COM> <281@cullsj.UUCP> Organization: Lockheed AI Center, Menlo Park Lines: 28 In article <281@cullsj.UUCP>, jayz@cullsj.UUCP (Jay Zorzy) writes: > From article <12387779883.20.STEINBERGER@KL.SRI.COM>, by STEINBERGER@KL.SRI.COM (Richard Steinberger): > > C vs. Fortran speed: Since C variables are automatic (i.e., dynamic) by > > default and Fortran variables are static, is it fair to conclude that in > > general, a routine in C having the same number of local variables as > > a "roughly identical" Fortarn routine will take a bit longer because > > the OS must allocate (and deallocate) space for the local variables? > > 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. I haven't looked at the compiler output for a long time, BUT... doesn't the allocation of automatic variables just involve adjusting the stack (and possibly frame) pointers? (In fact, I am pretty sure that this is what happens, but I have been known to be worng :-) If this is all that happens, then the size and number of automatic variables makes no difference at all to the overhead, which would just be one or two instructions. Since I don't know how FORTRAN allocates static variables (I hope they aren't put into a demand paged section :-) I would assume the C method is just as efficient. It is probably more efficient memory-wise since variables in rarely called routines never get allocated, whereas the memory for these variables would always hang around (of course, they could be paged out). -- Darin Johnson (...ucbvax!sun!sunncal!leadsv!laic!darin) (...lll-lcc.arpa!leadsv!laic!darin) All aboard the DOOMED express!