allocate a contiguous segment that is removed from the system memory map
#include <sys/seginfo.h> unsigned qnx_segment_raw_alloc( long nbytes, struct _seginfo *buf );
The qnx_segment_raw_alloc() function allocates a contiguous segment of memory that's removed from the system memory map. The physical address and size of the memory are returned in buf. Note that the size returned is rounded up to be a multiple of the page size used by the operating system (4K for 32-bit QNX).
This memory won't be returned to the memory map on the death of the process that allocated it. Once allocated, the system no longer believes that the memory exists. It can be returned only by explicitly calling qnx_segment_raw_free().
The _seginfo structure contains valid values for the following members:
#include <stdio.h> #include <errno.h> #include <process.h> #include <stdlib.h> #include <sys/seginfo.h> /* You must be root (uid == 0) to do raw allocations */ void main() { struct _seginfo buf; /* Display system memory, then alloc a chunk */ system( "sin in" ); if( qnx_segment_raw_alloc( 200000L, &buf ) == -1 ) { printf( "Alloc failed. Errno %d.\n", errno ); exit( 1 ); } /* Display system memory, then free a chunk */ system( "sin in" ); if( qnx_segment_raw_free( &buf ) == -1 ) printf( "Free failed (memory lost). Errno %d.\n", errno ); /* Display system memory */ system( "sin in" ); }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
Your application must run as root to call this function.