Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-24-2009, 08:30 AM   #1
LQ Newbie
Registered: Sep 2008
Posts: 4

Rep: Reputation: 0
Help needed: mmap and physical memory access

Hi All,

For some testing purpose I need to use mmap having file descriptor received out of /dev/mem. But, I have no idea about what offset I should use. It would certainly be very helpful if someone could suggest as what offset should I use. The required (desired) length is 1MB.
And, system I am using is FC9.

Manav Swargiary
Old 03-24-2009, 05:08 PM   #2
Registered: Mar 2009
Distribution: Fedora, Slackware
Posts: 104

Rep: Reputation: 21
Based on the mmap man page: "offset must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE)."

For sysconf itself see 'man sysconf'. The suggested solution is:

#include <unistd.h>
offset = sysconf(_SC_PAGE_SIZE);

Linux Archive

Last edited by JaksoDebr; 04-02-2009 at 05:06 AM.
Old 03-24-2009, 11:43 PM   #3
LQ Newbie
Registered: Sep 2008
Posts: 4

Original Poster
Rep: Reputation: 0
I will read and try out this solution. Thanks a lot.

Old 03-25-2009, 03:38 AM   #4
LQ Newbie
Registered: Sep 2008
Posts: 4

Original Poster
Rep: Reputation: 0
offset = sysconf(_SC_PAGE_SIZE);

This does not return the offset, instead it returns the size of a page.
I need a portion of a physical memory (preferably 1 MB) which is unused and can be accessed from user space using mmap. Offset (relative to base address) should point to an unused physical memory segment.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on using mmap to access physical memory Gnu2Linux2 Linux - Embedded & Single-board computer 1 10-05-2009 03:54 AM
How to access Physical memory not mapped in kernel sbc Programming 0 02-09-2009 09:13 AM
How to access physical (as opposed to virtual) memory in C language for a Linux app. ss729 Programming 2 12-23-2008 03:02 PM
mmap a physical address fardad Programming 3 10-30-2008 11:30 AM
How to access physical memory in C? cyu021 Programming 6 03-27-2005 04:16 AM

All times are GMT -5. The time now is 09:36 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration