#include "unify.h"
int Create_Seg(unsigned char type,
unsigned char status,
unsigned char prot,
unsigned len,
unsigned align)
Create_Seg() allocates a new segment with a length of
len bytes aligned on a align byte boundary.
type specifies the type of segment ot allocate. It may be
set to RANDOM_SEGMENT for random segments,
ASSOCIATIVE_SEGMENT for associative segments, or
SEQUENTIAL_SEGMENT for sequential segments.
status is LOCAL_SEGMENT if the segment is not
shared between machines or SHARED_SEGMENT if the segment
is shared.
prot indicates the type of accesses the segment is expected to receive. It is the logical OR of the following values:
The following are provided for use with align parameter:
On success a segment identifier is returned. Otherwise, a value of -1 is returned.
The following code fragment creates a byte aligned, shared random
segment of 100 bytes with read and write access.
int seg;
seg = Create_Seg(RANDOM_SEGMENT, SHARED_SEGMENT, R_ACCESS|W_ACCESS, 100, 1);
if( seg == -1 ) {
fprintf( stderr, "Segment creation failed\n" );
Unify_Close();
exit( -1 );
}