On Fri, 20 Aug 2010, Jussi Lehtola wrote: > On Fri, 20 Aug 2010 13:22:33 -0500 (CDT) > Michael Hennebry <hennebry@xxxxxxxxxxxxxxxxxxxxx> wrote: >> It makes sense that if a process insists on physically >> contiguous memory and can't get it, the process would die, >> but the above code does not tell the compiler what is to be achieved. >> >> In the following, would fred or greg necessarily >> refer to physically contiguous memory? >> >> #include <stdlib.h> >> extern void hank(char *); >> >> int main(*args[], int argsNum) >> { >> char fred[69000]; >> char *greg=malloc(96000); >> hank(fred); >> hank(greg); >> return 0; >> } > > If I remember my Kerningham-Ritchie correctly, the answer is yes, since > C relies on pointer arithmetic to refer to the elements of the array. > The "fred" and "greg" variables are pointers to the beginning of the > corresponding memory area, and referring fred[i] goes to the start of > the array at fred, and then goes i elements forward to end up with the > wanted element. That is contiguous in terms of virtual memory. Adjacent virtual addresses do not have to have adjacent physical addresses. -- Michael hennebry@xxxxxxxxxxxxxxxxxxxxx "Pessimist: The glass is half empty. Optimist: The glass is half full. Engineer: The glass is twice as big as it needs to be." -- users mailing list users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines