From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28345 invoked from network); 17 Aug 2020 20:44:55 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 17 Aug 2020 20:44:55 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id EE9429CAB6; Tue, 18 Aug 2020 06:44:51 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id C757C9E176; Tue, 18 Aug 2020 06:44:16 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=majumdar-org-uk.20150623.gappssmtp.com header.i=@majumdar-org-uk.20150623.gappssmtp.com header.b="REy8LUdI"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 6EA479CAB6; Tue, 18 Aug 2020 06:44:13 +1000 (AEST) Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by minnie.tuhs.org (Postfix) with ESMTPS id 2018A9CAB3 for ; Tue, 18 Aug 2020 06:44:12 +1000 (AEST) Received: by mail-lj1-f182.google.com with SMTP id i10so18996675ljn.2 for ; Mon, 17 Aug 2020 13:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=majumdar-org-uk.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gqUyVuz85VHh/npyS2QnFM0XSrr3MMwJ+idN/XjSk9Q=; b=REy8LUdIGVN/QfawCwQoryxN8oFvxlLlzWwkUu3IIxQsG0v3Q+oX0k7FLpzxx0c4Xp pdCkbtu9cj5gH9234gBo7JHLMMRJNE63yeFioiE0oamAkdKAOztvnV2q184XEJs9M77f VbfxzEpuKKPtg1xFZRN9vMIKJ9VHLpRW7AFd7Vkji3pg+TfvgRUDvNtWe/OJHVBSsbOj eNeBgX5rTwRKkb7vaE+QqkIQVMD2Xcqe/6ffxpO2T/uYm6PEB8dFIRaR7fqzJYXDkI8k NRZ2foMaTMMzEbgaz6Rp6Fz0PjmttdteFeI5bUtV3AA8JTQj7dd0JUJaO5tKxOvJ2Rcr G8aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gqUyVuz85VHh/npyS2QnFM0XSrr3MMwJ+idN/XjSk9Q=; b=iKcQyfgSCEKuODTvX1wdYu9z+vDcfufO1DMsofDds4T9kIBrQ1i9Jnys2BxSmysWuE t9hSIcFBAHeSjouGpcqV8rzu6geY/zm1XyftIS16k+bMO2bK1T80hgbm6HKmfspTcQDr sHX8hCKz/bQG4KBE1GxX6FvxZQ/+YipdCWzUZLtnkyBpXIWOniCKTuye1ECWMJIDXtT2 lyQt5/GthWn+2KUJ+EBpB9dJjt/KFM0tadKekWyfW2bL1DarSesstD2r5oqJKsrDaCIb HvWkHDTRt5w8vEqxgH0skWqDgG+pJ/JQcWAcETQmgX530gNWDWQs0CVRmEvU0ARLcWMV HVCg== X-Gm-Message-State: AOAM530fmMQDtMnjHgh2yZkjbVLLu9vbV2fNrmN+nl4/KXN9jBjo7Wy3 x04zJQyTFKVYCtIXsK9koE/9Fva10G+Zdp/+3rTxJQ== X-Google-Smtp-Source: ABdhPJwpWc2cL7b9B4XfWzQu72gGmMczvsUi88be10wULYZ2luCPs5BDiWQnuQiszx6CVhEjrF46x1qZp7a0svP93mU= X-Received: by 2002:a05:651c:330:: with SMTP id b16mr8214837ljp.77.1597697050479; Mon, 17 Aug 2020 13:44:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Dibyendu Majumdar Date: Mon, 17 Aug 2020 21:43:59 +0100 Message-ID: To: Paul Winalski Content-Type: text/plain; charset="UTF-8" Subject: Re: [TUHS] Memory management in Dennis Ritchie's C Compiler X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: The TUHS Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" On Mon, 17 Aug 2020 at 21:34, Paul Winalski wrote: > > On 8/17/20, Dibyendu Majumdar wrote: > > > > Yes, it only uses sbrk(). One consequence I think is that sbrk() > > expands the process memory without invalidating existing use of memory > > - so the code is able to periodically expand heap while retaining all > > existing allocations. > > If everyone does that, you can call other people's code without fear > of stepping on their memory when you allocate memory in your code. > Using a negative value to decrease the break is more problematic. > malloc() usually uses sbrk() to extend its heap. > > When we ported DEC's GEM compilation system to Unix, I used sbrk() to > extend memory and built my own multiple heap allocation scheme on top > of that. I could have used malloc() to allocate the heap chunks, but > there was no point. Might as well cut out the middleman. > Unfortunately sbrk() is not portable (I am building on Windows with MSVC too) and as far as I know was even removed from POSIX. >From Wikipedia: sbrk and brk are considered legacy even by 1997 standards (Single UNIX Specification v2 or POSIX.1-1998).[5] They were removed in POSIX.1-2001.[6] Regards Dibyendu