Re: memory management, allocation and collection in kernel mode.

From: doligez@pa.dec.com
Date: Sun Feb 14 1999 - 07:14:13 MET


From: doligez@pa.dec.com
Message-Id: <199902140614.AA17615@six.pa.dec.com>
To: "Sussillo, David" <sussillo@ftintl.com>
Subject: Re: memory management, allocation and collection in kernel mode.
In-Reply-To: Message of Wed, 10 Feb 99 11:51:00 PST
    from "Sussillo, David" <sussillo@ftintl.com>
Date: Sat, 13 Feb 1999 22:14:13 -0800

>From: "Sussillo, David" <sussillo@ftintl.com>

>Does anybody have an idea what would need to change in the OCaml memory
>management system in order for an OCaml program to function properly in
>kernel mode?

My first answer would be nothing at all if the kernel has a malloc
function.

>1. Will someone point out to me where I might look in the compiler
>source for all of the memory management routines, allocataion and GC? I
>guess it's important to see how the compiler reasons about the memory
>requirements of OCaml structures, as well as the emitted code (or
>libraries?) that it using during runtime.

I guess you should start with the byte-code interpreter, and when
that's working, you can tackle the native code stuff. The files to
look for are all in byterun:

alloc.[ch]
compact.[ch]
freelist.[ch]
gc.h
gc_ctrl.[ch]
major_gc.[ch]
minor_gc.[ch]
mlvalues.h
roots.[ch]
stacks.[ch]
weak.[ch]

>2. If anyone has any insight into the memory management ramifications of
>running an OCaml program in kernel mode, might they elucidate? As I'm
>just starting out, I'm interested in both general and specific remarks.

The memory management should be easy if you have malloc. For the
native code system, you might have to do something for the stack.

Stefan Monnier made a very good remark:
>3 - le kernel n'est souvent pas priemptible (?), donc il faudra faire attention
> ` appeler explicitement le yield() de temps ` autre pour ne pas perdre trop
> d'interruptions et ne pas rendre la machine unresponsive. O'Caml utilise
> dij` un GC incrimental si je ne me trompe, donc c'est peut-jtre pas trop
> difficile (famous last words).

Translation: since kernel code is never preempted, you'll have to call
yield() from time to time.

Fortunately, that is exactly what the Macintosh version does for
cooperative multi-tasking. Look for "#if macintosh" in interp.c and
replace the call to rotatecursor_action() with yield(). That should
be enough. For native code, I don't have an easy answer.

-- Damien



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:19 MET