Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 71C437C73 for ; Tue, 29 Nov 2011 09:50:14 +0000 (UTC) Received: (qmail 76754 invoked by uid 500); 29 Nov 2011 09:50:13 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 76728 invoked by uid 500); 29 Nov 2011 09:50:12 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 76718 invoked by uid 99); 29 Nov 2011 09:50:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Nov 2011 09:50:09 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [217.22.192.104] (HELO www.elogos.de) (217.22.192.104) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Nov 2011 09:50:02 +0000 Received: by www.elogos.de (Postfix, from userid 1001) id A7EDC9006D; Tue, 29 Nov 2011 10:59:28 +0100 (CET) Date: Tue, 29 Nov 2011 10:59:28 +0100 From: rm@tuxteam.de To: modules-dev@httpd.apache.org Subject: Re: Binary Tree Shared Memory Problem Message-ID: <20111129095928.GA26783@seid-online.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.15+20070412 (2007-04-11) On Tue, Nov 29, 2011 at 12:29:20AM +0200, O??uzhan TOPG?L wrote: > Hi, is there any example mod_slotmem codes that we can understand the > usage? Have you looked at the code? 'mod_slotmem_shm.c' is less than 650 lines of code, 'mod_slotmem_plain.c' less than 300. Sorry, but you have to do _some_ reading yourself. > Or could you give me an usage example? For example we are using > apr_shm_create() in post_config, but mod_slotmem is a little bit hard to > understand i think. > And i want to ask a question, > is it a problem to create > > typedef struct node { > ELEMENT node_element; > struct node *left; > struct node *right; > }NODE; > > kind of struct. A struct that has two struct elements. No, it doesn't. It holds two _pointers_ to node structures (learn some C as well ..). You can't share such a structure since the address in *left or *right will only be valid in one process. You could store an offset to the node's base address in left/right and write some support code to do all the pointer magic to get/set these values but you still would need to write your own memory allocator and tree balancing code and somehow I get the feeling that's to demanding a task ... We've had similr questions in the ML just recently - consult the archive. HTH Ralf Mattes > As i mentioned > before what i'm trying to implement is a binary tree as a data structure. > > regards > > O??uzhan TOPG�L > > > On Mon, Nov 28, 2011 at 11:52 PM, Ignaz Birnstingl wrote: > > > Hi, > > > > apr_shm_baseaddr_get returns the base address for the shared memory > > segment. You will have to implement your own "allocator" within the shared > > memory. Also keep in mind that you can't reliably use pointers inside the > > shared memory segment, because - as the documentation states - the address > > returned by apr_shm_baseaddr_get "is only usable within the callers address > > space, since this API does not guarantee that other attaching processes > > will maintain the same address mapping." > > Inter- and intra-process synchronization will be problems you will > > encounter later on. > > Btw Apache 2.3 offers mod_slotmem which helps in using shared memory - > > maybe you should have a look at it? > > > > -- Ignaz > >