10-11-2010
You can open /dev/mem directly; it is already memory, you do not need mmap.
/dev/kmem is kernel, /dev/port ports. /dev/[anything] is a virtual file, kernel resident & linked ( as in ln ) via a psuedo-device that is part of active memory, like /proc.
DDD and similar tools are probably easier to use than just writing code in C. In order not to crash your box you should open any of those read-only until you learn more about it.
10 More Discussions You Might Find Interesting
1. Filesystems, Disks and Memory
Hello. I'm writing some random access i/o software on Solaris 8 using mmap64 to memory map large files (my test file is ~25 GB).
The abbreviated code fragment is:
fd = open(cbuf,O_RDONLY|O_LARGEFILE);
struct stat statbuf;
fstat(fd,&statbuf);
off_t len =... (0 Replies)
Discussion started by: gusm
0 Replies
2. UNIX for Dummies Questions & Answers
the various distros of free Linux and other *nix OSes?
I'm curious. (1 Reply)
Discussion started by: hype.it
1 Replies
3. UNIX for Dummies Questions & Answers
What is the difference bettween linux and unix?
Sorry but I am really new to this! :confused:
Also are they BOTH free :-D (1 Reply)
Discussion started by: jamesthemagicia
1 Replies
4. Shell Programming and Scripting
Hi,
whats the difference between $* and $@ in command line arguments to a shell scripts (3 Replies)
Discussion started by: pbsrinivas
3 Replies
5. UNIX for Dummies Questions & Answers
can some one please explain
zombie
orphan
defunct
and how they r related (3 Replies)
Discussion started by: pbsrinivas
3 Replies
6. UNIX for Dummies Questions & Answers
Hi,
In linux we have exit status variable ($?) and status which tells whether last command was successfull or not. Can someone please tell me what is difference between both. Both tells whether command was successful or not, Any particular difference between them?
Thanks in Advance.
Thanks... (3 Replies)
Discussion started by: sarbjit
3 Replies
7. Programming
how to use mmap() to map a file to memory space. Do you have any simple program???? Because I have to implement lot of concepts into it. (5 Replies)
Discussion started by: gokult
5 Replies
8. Homework & Coursework Questions
Descriptions:
Develop a program that uses mmap() to map a file to memory space. Prepare such a file by yourself and do the follows.
<LI class=MsoNormal>Display the content of the file after mapping; <LI class=MsoNormal>Output how many digits included in the file; <LI class=MsoNormal>Replace... (1 Reply)
Discussion started by: gokult
1 Replies
9. Programming
hai,
How do we map 'n' number of files into memory by using mmap system call??
Thanks in advance...... (5 Replies)
Discussion started by: andrew.paul
5 Replies
10. Emergency UNIX and Linux Support
I want to know whether this is possile or ever been tried out.
I want to obtain a chuck of memory using mmap()
I do it so :
n = mmap(0, 8000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
And hold on to that memory, when a process requests for memory, some memory is... (2 Replies)
Discussion started by: xerox
2 Replies
LEARN ABOUT SUNOS
mapmalloc
mapmalloc(3MALLOC) Memory Allocation Library Functions mapmalloc(3MALLOC)
NAME
mapmalloc - memory allocator
SYNOPSIS
cc [ flag ... ] file ... -lmapmalloc [ library ... ]
#include <stdlib.h>
void *malloc(size_t size);
void *calloc(size_t nelem, size_t elsize);
void free(void * ptr);
void *realloc(void *ptr, size_t size);
DESCRIPTION
The collection of malloc functions in this library use mmap(2) instead of sbrk(2) for acquiring new heap space. The functions in this
library are intended to be used only if necessary, when applications must call sbrk(), but need to call other library routines that might
call malloc. The algorithms used by these functions are not sophisticated. There is no reclaiming of memory.
The malloc() and free() functions provide a simple general-purpose memory allocation package.
The malloc() function returns a pointer to a block of at least size bytes suitably aligned for any use.
The argument to free() is a pointer to a block previously allocated by malloc(), calloc() or realloc(). If ptr is a NULL pointer, no
action occurs.
Undefined results will occur if the space assigned by malloc() is overrun or if some random number is handed to free().
The calloc() function allocates space for an array of nelem elements of size elsize. The space is initialized to zeros.
The realloc() function changes the size of the block pointed to by ptr to size bytes and returns a pointer to the (possibly moved) block.
The contents will be unchanged up to the lesser of the new and old sizes. If the new size of the block requires movement of the block, the
space for the previous instantiation of the block is freed. If the new size is larger, the contents of the newly allocated portion of the
block are unspecified. If ptr is NULL, realloc() behaves like malloc() for the specified size. If size is 0 and ptr is not a null pointer,
the space pointed to is freed.
Each of the allocation functions returns a pointer to space suitably aligned (after possible pointer coercion) for storage of any type of
object.
The malloc() and realloc() functions will fail if there is not enough available memory.
Entry points for malloc_debug(), mallocmap(), mallopt(), mallinfo(), memalign(), and valloc() are empty routines, and are provided only to
protect the user from mixing malloc() functions from different implementations.
RETURN VALUES
If there is no available memory, malloc(), realloc(), and calloc() return a null pointer. When realloc() returns NULL, the block pointed to
by ptr is left intact. If size, nelem, or elsize is 0, a unique pointer to the arena is returned.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|MT-Level |Safe |
+-----------------------------+-----------------------------+
SEE ALSO
brk(2), getrlimit(2), mmap(2), realloc(3C), malloc(3MALLOC), attributes(5)
SunOS 5.10 20 Feb 2004 mapmalloc(3MALLOC)