shmat()

8592x2 jeff at astph.UUCP
Sat Aug 25 06:25:34 AEST 1990


I begun to code my initial shared memory manager after many
helpful tips from the net. We have decided to code for the
most portable usage of the shmat() system call. It is our goal
to run our database on different systems with little or no
modification. Thanks for your advice.

Our database will work with a server/client process architecture.
The server and client will all need access into this shared
memory. We plan to allow the system to select the address to
map each process into the shared memory. The FM describes how
to make the shmat() and allow the system to select the address.

With in this shared memory we will use many queues, free queues,
record queues, etc. We do not want to use absolute pointers
within these queues because the system may allign the shared memory to
a different address with each shmat(). Thus we will use offsets
from the beginning of the shared memory segment. The queue
structures follow.

    typedef	struct {
	unsigned	short	offset; /* segment index */
	unsigned	char	segment;/* segment identifier */
    } SQUEUE;	/* singly linked list queue pointer */

    typedef	struct {
	SQUEUE			fore;	/* fore pointer */
	SQUEUE			back;	/* back pointer */
    } DQUEUE;	/* doubly linked list queue pointer */

The above structures will provide a relative 'offset' into a shared
memory segment and an identifier to a particular memory 'segment'.
Thus we can create a large shared memory segment (1 meg max) and
provide enough pointers. However if we need more than one meg we
can create another shared memory segment and use the 'segment'
field to point to another memory segment.

Database programmers what do you think?

Thanks,			jeff martin
			astph!jeff at psuvax1.psu.edu
			psuvax1!astph!jeff
			philadelphia phillies



More information about the Comp.unix.wizards mailing list