delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/06/15/13:19:43

X-Spam-Check-By: sourceware.org
Date: Thu, 15 Jun 2006 19:19:28 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: sysconf(_SC_PAGESIZE) set to 64k
Message-ID: <20060615171928.GB16683@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <153F17DAEC71B743B926B2AE6CA04FDA03BDA7 AT WOLVES DOT renovosoftware DOT com> <002d01c69085$5d97aff0$a501a8c0 AT CAM DOT ARTIMI DOT COM>
Mime-Version: 1.0
In-Reply-To: <002d01c69085$5d97aff0$a501a8c0@CAM.ARTIMI.COM>
User-Agent: Mutt/1.4.2i
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Jun 15 15:09, Dave Korn wrote:
> On 15 June 2006 14:56, Ehren Jarosek wrote:
> 
> > I don't know if this is something I am doing wrong or an issue.
> > 
> > When compiling under cygwin sysconf(_SC_PAGESIZE) returns 65536 (64k)
> > memory page size.  My understanding is that:
> > 
> > sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES)
> > 
> > should yield the total physical memory size of the machine.  However,
> > when I do this it yields a very large number (actually overflows my
> > long).  However, if I multiply sysconf(_SC_PHYS_PAGES) * 4096 it yields
> > the correct size.
> 
> Alas there is a problem with the definition of sysconf: it is
> supposed to be the size of the unit of granularity of mmap'ing, but
> it is also supposed to be the size of a single pageframe of memory.
> [...]

_SC_PAGESIZE is only for indicating the page size as used in calls to
mmap(2).  POSIX does not demand that _SC_PAGESIZE is actually the
physical page size.

Two quotes from the Linux man pages:

  $ man getpagesize
  [...]
   The  function  getpagesize()  returns  the  number of bytes in a page,
   where a "page" is the thing used where it says in the  description  of
   mmap(2) that files are mapped in page-sized units.

   The size of the kind of pages that mmap uses, is found using

	  #include <unistd.h>
	  long sz = sysconf(_SC_PAGESIZE);


  $ man sysconf
  [...]
   These values also exist, but may not be standard.

   - _SC_PHYS_PAGES
	 The number of pages of physical memory.  Note that it is possi-
	 ble   for   the   product  of  this  value  and  the  value  of
	 _SC_PAGE_SIZE to overflow.


So, actually Ehren's application works on Linux just coincidentally,
since it make invalid assumptions.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019