From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA07892 for caml-redistribution; Sun, 14 Feb 1999 19:22:17 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA31013 for ; Sun, 14 Feb 1999 07:14:48 +0100 (MET) Received: from mail1.digital.com (mail1.digital.com [204.123.2.50]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id HAA10591 for ; Sun, 14 Feb 1999 07:14:46 +0100 (MET) From: doligez@pa.dec.com Received: from six.pa.dec.com (six.pa.dec.com [16.4.80.66]) by mail1.digital.com (8.9.1a/8.9.1/WV2.0d) with SMTP id WAA27896; Sat, 13 Feb 1999 22:14:45 -0800 (PST) Received: by six.pa.dec.com; id AA17615; Sat, 13 Feb 1999 22:14:14 -0800 Message-Id: <199902140614.AA17615@six.pa.dec.com> To: "Sussillo, David" Cc: "'caml-list@inria.fr'" 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" <36C1E9EF@smtp.ftintl.com> Date: Sat, 13 Feb 1999 22:14:13 -0800 X-Mts: smtp Sender: weis >From: "Sussillo, David" >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