From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA12959; Sat, 8 Jun 2002 15:36:23 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA12985 for ; Sat, 8 Jun 2002 15:36:22 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g58DaFH06696; Sat, 8 Jun 2002 15:36:15 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA12984; Sat, 8 Jun 2002 15:36:14 +0200 (MET DST) Date: Sat, 8 Jun 2002 15:36:14 +0200 From: Xavier Leroy To: Gerd Stolpmann Cc: Fernando Alegre , caml-list@inria.fr Subject: Re: [Caml-list] camlimages and kernel memory Message-ID: <20020608153614.A12902@pauillac.inria.fr> References: <20020605234852.GA4103@oso.local> <20020606230826.C616@ice.gerd-stolpmann.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20020606230826.C616@ice.gerd-stolpmann.de>; from info@gerd-stolpmann.de on Thu, Jun 06, 2002 at 11:08:26PM +0200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > For example, Linux (but other OS, too) allow userland processes to access the > kernel memory by opening and mmapping the file /dev/kmem. This effects that > kernel memory is mapped into the userland address space. However, mmap is > usually restricted to 4k blocks, i.e. you can mmap only a whole number of > 4k blocks. > > O'Caml can handle pointers to blocks that are outside of the region that is > managed by its own routines. The blocks must have the right format, of course, > i.e. strings must have the right O'Caml header. I suppose this header is not > in the ringbuffer. > > If the ringbuffer happens to begin at a 4k boundary, you have won, because you > can manage that there is such a header without modifying kernel memory, i.e. > if the mmaped buffer begins at address A, just allocate anonymous memory in the > 4k block before A and write the needed header into it. This is the hard way :-) A simpler way to memory map files or devices in a Caml program is to use the function "map_file" from the Bigarray library. However, it currently always map the file from offset 0, which is probably not appropriate for /dev/kmem... I'll have to look into this limitation. > The other problem is whether camlimages can handle data that is > organized as ring. I don't have any ideas. The type Image.t is a relatively complex data structure, so some work is definitely needed to go from a raw string or bigarray (corresponding to the memory-mapped file) to a value of type Image.t. I'll let the authors of CamlImages comment on that. - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners