From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id F2395BC57 for ; Thu, 18 Mar 2010 19:33:04 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgECAEMOokvVhjEXkWdsb2JhbACbQgEBAQEJCwoHEwMfuiCCS4IuBA X-IronPort-AV: E=Sophos;i="4.51,268,1267398000"; d="scan'208";a="47102986" Received: from ihsmtp01voda.lis.interhost.com (HELO ihsmtp01cons.lis.interhost.com) ([213.134.49.23]) by mail3-smtp-sop.national.inria.fr with ESMTP; 18 Mar 2010 19:33:03 +0100 Received: from [192.168.1.64] ([95.136.106.136]) by ihsmtp01cons.lis.interhost.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Mar 2010 18:33:02 +0000 Message-ID: <4BA271D2.9030602@inescporto.pt> Date: Thu, 18 Mar 2010 18:32:50 +0000 From: Hugo Ferreira User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Shared data space: How to manage Ancient keys? Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 18 Mar 2010 18:33:02.0420 (UTC) FILETIME=[713F9940:01CAC6C9] X-Spam: no; 0.00; ocaml:01 dynamically:01 integer:01 reuse:01 algorithm:01 linear:02 data:02 data:02 tree:02 tree:02 binary:02 binary:02 indexing:02 objects:02 objects:02 Hello, I am trying to implement a parallel algorithm and have opted to use the Ancient module to share data across processes because it dynamically reallocates memory when mapping data (I don't know the size of the objects before hand). However I am having trouble managing its use of keys. Maybe someone here has a solution to my problem. To make things clear - a little background. I have a set of worker processes that cooperate to analyse a set of sequences. I assume all sequences are in a global blackboard-type /LINDA-like data space. Each worker removes a single sequence. It then scans all other existing sequences and selects another one. It then a) removes the selected sequence b) merges the 2 sequences at hand and generates 0, 1 or more new sequences. The process repeats itself until no more sequences exist in the global data space. In the above scenario all sequences would be assigned a unique id which increases sequentially. If I used a common data structure such as a binary tree I could simply increment a counter and use that as a key for the insertion/deletion of sequences into/from the binary tree. However I cannot do this here because I can only share linear memory via mapped files in Ocaml. So far I have made a small experiment that allows me to insert data into a shared memory space. Ancient allows one to copy various objects into the memory space via an integer index. From the code it seems that the indexing table is an array like structure. So when I add and object I must identify an index (slot) that is empty (unused) and reuse that otherwise memory will grow unchecked. My question is how can I generate and share keys for Ancient's use without exceeding memory usage? TIA, Hugo F.