allocate a segment, setting option flags
#include <sys/seginfo.h> unsigned qnx_segment_alloc_flags( long nbytes, unsigned flags );
The qnx_segment_alloc_flags() function allocates a segment of memory nbytes long from the operating system. It's identical to qnx_segment_alloc() except it allows you to specify some option flags on the allocated segment.
The following special flags are supported. Note that _PMF_MODIFY is always set for you. You can remove it using qnx_segment_flags().
Although this function is available in both the 16-bit and 32-bit libraries, the qnx_segment_... family of calls is primarily intended for the 16-bit segmented version of QNX. To allocate and share memory in the 32-bit version you should look at using the POSIX shm_open() and mmap() functions. |
A segment number on success. On error, it returns -1, and errno is set.
#include <i86.h> #include <sys/seginfo.h> void main() { unsigned base; char __far *p; /* Allocate a globally accessible 32 Kbyte array */ base = qnx_segment_alloc_flags( 32768, _PMF_GLOBAL | _PMF_GLOBAL_OWN ); /* Point at byte 16,000 in the array */ p = MK_FP( base, 16000 ); /* Set the byte and read it back */ *p = 'a'; printf( "base = %u, p = %08lx\n", base, p ); printf( "*p = %c\n", *p ); /* * The pointer 'p' can now be passed to any other * process that may want to access this shared * memory. */ }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
errno, qnx_segment_alloc(), qnx_segment_arm(), qnx_segment_flags(), qnx_segment_free(), qnx_segment_get(), qnx_segment_huge(), qnx_segment_index(), qnx_segment_info(), qnx_segment_overlay_flags(), qnx_segment_overlay(), qnx_segment_put(), qnx_segment_raw_alloc(), qnx_segment_raw_free(), qnx_segment_realloc()