PAGE ALLOCATION ??

PAGE ALLOCATION ??

Post by CHAD » Tue, 12 Jul 1994 14:26:20



Hi Netters,

        I am looking for some ways to get memory from the system in pages
using system calls.

        There should be some way of protecting these pages and a handler
should be called if the particular page is not in the system.

        Any approach is welcome.

Saurabh.

 
 
 

PAGE ALLOCATION ??

Post by Michael Salm » Tue, 12 Jul 1994 18:59:11



|>   I am looking for some ways to get memory from the system in pages
|> using system calls.

The usual way is with brk or sbrk.

|>   There should be some way of protecting these pages and a handler
|> should be called if the particular page is not in the system.

Protecting them from what? mprotect can set the protection on pages.
Does "not in the system" mean not physically resident? mlock can lock
pages in memory.

--

Michael Salmon

#include        <standard.disclaimer>
#include        <witty.saying>
#include        <fancy.pseudo.graphics>

Ericsson Telecom AB
Stockholm

 
 
 

PAGE ALLOCATION ??

Post by Steven Buytae » Tue, 12 Jul 1994 18:26:58


: Hi Netters,
:      
:       I am looking for some ways to get memory from the system in pages
: using system calls.

:       There should be some way of protecting these pages and a handler
: should be called if the particular page is not in the system.

:       Any approach is welcome.

 This is system dependent. See if your system supports the
 getpagesize() call. If not, your page size is probably
 2048 bytes. Use the brk() call to get this amount of bytes.
 Use one call to brk, requesting size 0 and then check if the
 returned pointer starts on a 2048 byte boundary, if not,
 you request the number of bytes separating you from the
 page boundary, the next call to brk(2048) will give you
 one page then. Make sure you have somewhere a memory
 tracking system because you have to give the memory
 back afterwards.

 So, in short, check out the man pages for
 - getpagesize()
 - brk()
 - all man pages referred in the two above

 Good luck,

 Stef

--
Steven Buytaert



        'Imagination is more important than knowledge.'
                        (A. Einstein)

 
 
 

PAGE ALLOCATION ??

Post by Jim Mauro - SE - Somerset » Fri, 15 Jul 1994 21:52:16


Quote:

>>        I am looking for some ways to get memory from the system in pages
>>using system calls.

I'm not aware of any UNIX implementations that provides a system call or
library function to do this. The traditional methods of getting memory
(malloc, mmap of /dev/zero) require that you specify how much memory you
want in bytes, not pages.

Of course, the system must round up to the nearest page what actually gets
allocated to the processes VA space, since a page is the smallest unit the
OS can allocate/map/protect.

If you're interested in pages, than I suggest you use an implementation
specific routine to get the systems page size (sysconf(SC_PAGESIZE) in
solaris, getpagesize(2) is BSD, etc) and do the arithmetic in your code,
althought it is not clear to me what use this information would be.

Quote:

>>        There should be some way of protecting these pages and a handler
>>should be called if the particular page is not in the system.

Unless I'm completely misinterpreting what you're asking, you concerning yourself
with things you do not need to concern yourself with. The OS will page-in on
an as needed basis. You can use routines like memcntl(3) to tweak the permissions
of pages you own.

/jim

 
 
 

PAGE ALLOCATION ??

Post by Patrick J. Horg » Thu, 21 Jul 1994 08:51:20


Look at the man pages for mmap, munmap, plock, mlockall, sysconf, etc...

Patrick
--

     These opinions are mine, and not Amdahl's (except by coincidence;).

    ~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~  
  /                        |                           | (\               \
 |  Patrick J. Horgan      |  Amdahl Corporation       |  \\    Have       |

 |  Phone : (408)992-2779  |  P.O. Box 3470 M/S 201    |    \\/    Will    |
 |  FAX   : (408)773-0833  |  Sunnyvale, CA 94088-3470 |   _/\\     Travel |
  \                        |                           |      \)          /
   ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

 
 
 

1. page allocation vs program performance

Hi,

Usually a program is optimized in its memory access pattern
with respect to virtual memory (e.g, a good data layout
so that ("virtual") cache misses are reduced.). Since most of
the microprocessors use physical caches, physical page allocation
becomes important to determine the final performance of the
optimized program. As I understand it, UNIX's page allocation
is to allocate the top of the free list of physical pages.
In this way, there is no guarantee the preservation of the
"tuned" memory access pattern, and thus performance.
Page coloring is a way to remedy this indeterminacy.

But I wonder how many commerical OSes have implemented such
careful page allocation policies?

Since I am working on Solaris 2.5.1 now, any pointer of how
Solaris 2.x does a better job than simply allocating the top
page would be very much appreciated.

Chung-Hsing Hsu

[PS. Unfortunately, our school is still negotiating with Sun
     for source code of Solaris; therefore, I have no way to
     take a look at how Solaris does page allocation.]

2. Help, Mandrake 9.0 cannot start nor shut down

3. page allocation failure. order:0, mode:0x0

4. Question about mounting multisession CD on AIX 4.1

5. page allocation vs program performance

6. Linux Mailing List

7. Page allocation error

8. Strategic Security Consultant in Seattle

9. kernel BUG at page_alloc.c:92! & page allocation failure. order:0, mode:0x0

10. 2.5.13 error: kswapd: page allocation failure. order:0 mode:0x20

11. 2.5.53-mm3: xmms: page allocation failure. order:5, mode:0x20

12. kernel BUG at page_alloc.c:92! & page allocation failure. order:0, mode:0x0

13. Guard Page for stack allocation