[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

9677.0. "Any way to shmat to pointer to structure?" by NNTPD::"[email protected]" (Ann Harrold) Wed Apr 30 1997 11:04

Hi,
I am hoping someone can help with this.  Sorry if it is a simple question -
kind of new at this.
I am trying to port some code from vms to unix - and in the vms code there
seems to be a way to define and name a structure and pointer to a
structure, then create a global section at the starting address of the
structure.  I am trying to do something similar in unix - but I am not
sure if I can do it.  I read through note 1756 - and I can't quite tell if
this is possible.
Example:

struct gs_fixed_info
        {
        long sub_proc_ready_cnt;
        long total_cpus;
        };
struct gs_fixed_info gs;
struct gs_fixed_info *gs_ptr

main()

int sh_mem_id;
void *ptr;

gs_ptr = &gs;
gs_size = sizeof(struct gs_fixed_info)

sh_mem_id = shmget(IPC_PRIVATE, gs_size, IPC_CREAT|SHM_R|SHM_W);
ptr = shmat(sh_mem_id, gs_ptr, SHM_RND);
}

So, in effect create a shared memory section, and a pointer to a structure,
and map the shared memory section to the structure - so that all updates
to the structure can be seen by all processes attached to the shared memory
section.  And all processes attached to the shared memory section can update
it by making changes to the structure.  The other alternative I thought of
would be to do updates to an offset into the shared memory section and not
use any structure references.

Does anyone know of a way to get around this?  The above example gives
errno 12 Not enough space.

Thanks in advance,

Ann

[Posted by WWW Notes gateway]
T.RTitleUserPersonal
Name
DateLines
9677.1may18.zko.dec.com::bobFor Internal Use OnlyWed Apr 30 1997 11:453
try:

gs_ptr = shmat(sh_mem_id, 0, SHM_RND);