Create_Seg(3)

Synopsis

cc [ flag ... ] file ... -lunify -levents -lpvm3 -lgpvm3 -lthread -ll -lsocket -lnsl -lw -lposix4 -lucb [ library ... ]

#include "unify.h"

int Create_Seg(unsigned char type, unsigned char status, unsigned char prot, unsigned len, unsigned align)

Description

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:

X_ACCESS
If the segment is executable.
W_ACCESS
If the segment is writable.
R_ACCESS
If the segment is readable.

The following are provided for use with align parameter:

ALIGN_BYTE
Alignment appropriate for bytes.
ALIGN_16BIT
Alignment appropriate for 16 bit entities.
ALIGN_32BIT
Alignment appropriate for 32 bit entities.
ALIGN_CHAR
Alignment appropriate for characters.
ALIGN_SHORT
Alignment appropriate for short integers.
ALIGN_INT
Alignment appropriate for integers.
ALIGN_LONG
Alignment appropriate for long integers.
ALIGN_FLOAT
Alignment appropriate for single-precision floating-point numbers.
ALIGN_DOUBLE
Alignment appropriate for double-precision floating-point numbers.

Return Values

On success a segment identifier is returned. Otherwise, a value of -1 is returned.

Examples

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 );
}

See Also

unifyintro(3), Destroy_Seg(3), Unify_Close(3)

BugsAssociative segments are not implemented.

RCS status $Id: Create_Seg.html,v 1.2 1998/02/02 23:19:01 dieter Exp $