give another process shared access to a segment
#include <sys/seginfo.h> unsigned qnx_segment_put( pid_t pid, unsigned segment, unsigned flags );
The qnx_segment_put() function is used to give process pid shared access to the calling process's segment. If pid is zero, the calling process is used. Otherwise, the other process must have given you access to give the segment by calling qnx_segment_arm().
The segment returned by this call won't, in general, be the
same as the segment passed as an argument:
You would typically pass the value of the new segment to the other process using a message exchange. If the flags argument contains _PMF_ALIGN, a segment is allocated in both your LDT and the pid's LDT, which are the same. This can sometimes be useful if a segment is in a common table accessed by two processes. |
By default, the flags of the source segment are inherited. If the flags argument contains _PMF_INUSE, the following flags are taken from the flags argument:
In this case you MUST specify all flags that you want passed to the new segment.
#include <stdio.h> #include <i86.h> #include <process.h> #include <unistd.h> #include <sys/kernel.h> #include <sys/seginfo.h> pid_t childpid; struct { unsigned seg; } msg; void main() { if( childpid = fork() ) parent(); else child(); } void parent() { unsigned seg; qnx_segment_arm( childpid, -1, 0 ); Send( childpid, &msg, &msg, sizeof( msg ), sizeof( msg ) ); seg = msg.seg; printf( "Parent seg %4.4X.\n", seg ); } void child() { unsigned seg; unsigned char buf[100]; pid_t pid; seg = FP_SEG( buf ); printf( "Child seg %4.4X.\n", seg ); pid = Receive( 0, &msg, sizeof( msg ) ); msg.seg = qnx_segment_put( pid, seg, 0 ); Reply( pid, &msg, sizeof( msg ) ); }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
errno, qnx_segment_alloc(), qnx_segment_alloc_flags(), 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_raw_alloc(), qnx_segment_raw_free(), qnx_segment_realloc()