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 XAA12305; Thu, 6 Jun 2002 23:08:36 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 XAA12314 for ; Thu, 6 Jun 2002 23:08:35 +0200 (MET DST) Received: from moutng1.kundenserver.de (moutng1.kundenserver.de [212.227.126.171]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g56L8Yr10358 for ; Thu, 6 Jun 2002 23:08:34 +0200 (MET DST) Received: from [212.227.126.160] (helo=mrelayng0.kundenserver.de) by moutng1.kundenserver.de with esmtp (Exim 3.22 #2) id 17G4Uh-0005sW-00; Thu, 06 Jun 2002 23:08:31 +0200 Received: from [80.129.100.225] (helo=gate.gerd-stolpmann.de) by mrelayng0.kundenserver.de with asmtp (Exim 3.35 #1) id 17G4Uh-0006Qp-00; Thu, 06 Jun 2002 23:08:31 +0200 Received: from ice.gerd-stolpmann.de (ice.gerd-stolpmann.de [192.168.0.13]) by gate.gerd-stolpmann.de (Postfix) with ESMTP id 39240CCDD; Thu, 6 Jun 2002 23:08:28 +0200 (CEST) Received: from ice (localhost [127.0.0.1]) by ice.gerd-stolpmann.de (Postfix) with ESMTP id 2DE921AD7B; Thu, 6 Jun 2002 23:08:27 +0200 (MEST) Date: Thu, 6 Jun 2002 23:08:26 +0200 From: Gerd Stolpmann To: Fernando Alegre Cc: caml-list@inria.fr Subject: Re: [Caml-list] camlimages and kernel memory Message-ID: <20020606230826.C616@ice.gerd-stolpmann.de> References: <20020605234852.GA4103@oso.local> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit In-Reply-To: <20020605234852.GA4103@oso.local>; from fernando@cc.gatech.edu on Thu, Jun 06, 2002 at 01:48:52 +0200 X-Mailer: Balsa 1.2.4 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On 2002.06.06 01:48 Fernando Alegre wrote: > > Hi, > > We would like to use some kernel memory buffers from the camlimages libraries > without copying the data to userland. The data comes from digital cameras > directly (using DMA) to a kernel ringbuffer. Caml does not own that memory, > but we want Caml to use it as just another Image.t chunk (with a wrapper, > of course.) > > Our question is: is there a safe way to do this? We don't want the garbage > collector to mess with the kernel memory, but we don't want to have > to code separately for "userland" and "kernel" images... > > Any suggestion will be appreciated. One important information is missing: which operating system? 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. In all other cases, you must modify kernel memory to ensure that there is a header. I don't know whether this is possible. The other problem is whether camlimages can handle data that is organized as ring. I don't have any ideas. Gerd -- ---------------------------------------------------------------------------- Gerd Stolpmann Telefon: +49 6151 997705 (privat) Viktoriastr. 45 64293 Darmstadt EMail: gerd@gerd-stolpmann.de Germany ---------------------------------------------------------------------------- ------------------- 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