[SqNOS] Memory, ideas?

Gerardo Richarte gera at corest.com
Sun Jul 2 22:54:24 UTC 2006


> Ideas (3):
>   

Ideas (4) [just got the easiest]:
    . We've done the most stupid implementation of calloc() and free()
in order to build the VM without any changes [code at the end]. This
simple implementation has a 1MB buffer, and always returns from the end
(free just calls exit()).
    We could map this calloc() to be accesible from Squeak, and use it
for this external buffers. This is not a solution to the problem, as the
memory will quite likely get consumed pretty soon, but it will let us
continue coding, until somebody comes with a nice solution :-)

    I'm happy, I can go on!
    anyway, don't forget about this, we need to solve it.

    gera

PS: Code for calloc() and free() as reference.


#define HEAP_SIZE       1024*1024
void *calloc(unsigned int count, unsigned int size) {
        static char heap[HEAP_SIZE];
        static char *heap_end = &heap[HEAP_SIZE];
        static char *heap_new=heap;

        unsigned long long total;
        total = count * size;

        if (heap_new + total < heap_end) {
                char *answer = heap_new;
                heap_new += total;
                return answer;
        }
        printf("calloc(%d, %d)\n", count, size);
}

void free(void *p) {
        printf("free(%x)\n",p);
        ioExit();
}



More information about the SqueakNOS mailing list