Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 03 Nov 2002 11:38:33 +1300
From:      Dave & Julia Smith <barak@globe.net.nz>
To:        freebsd-hackers@freebsd.org
Subject:   Hi folk, needing basic help with shared mem
Message-ID:  <3DC453E9.5040500@globe.net.nz>

next in thread | raw e-mail | index | archive | help
Hi folk, I appoligize in advance if I am emailing to the wrong group as 
I just got this group
from an EFNet question response.

What I am trying to do is create a simple message parser library for 
applications to access,
NOT using any of the main BSD components like pipes and sockets.
The coding of the message system should not be a problem, my problem 
lies in creating
a library that can hold and parse information between calling applications.
i.e my library has for example a func PostMessage(int app, word msg); 
and SendMessage(int app, word msg);
for argument sake.. All this is fine, however, I am finding, that even 
though I have created
my library as a shared lib, each time the lib is called by an app the 
lib knows nothing about the previous
calls.
I am assuming this is in the memory handling technique, and this is 
where I am falling down, thus far
I have played with shm_open() and mmap() but still, it's like the lib 
can't find anything from a previous
call to itself by another app. (I HOPE I make sense here).

Just incase I am not making myself clear, this is the flow of how my app 
works...

MainApp (which runs continuously in an infinte loop loads the Lib at 
time of init and calls SetUpMapping,
since this app is always in memory, then the lib is not unloaded.)

bool    SetUpMapping()
{
    int dis_mem = shm_open("Physical",  O_RDWR | O_CREAT, 00777 );
    if (dis_mem==-1)
    {
        printf("Failed to mmap()\n");
        return false;
    }
    dis_buff=(char*)mmap(0, 1048576, PROT_READ | PROT_WRITE, MAP_SHARED 
, dis_mem, 0);
    return true;
}


Calling Applications call the Libs GetMessage and SendMessage functions 
which work with dis_buff to determine
messages etc.

Part of my problem here is probably sdue to the fact that I have just 
come over from the Win32 platform and
grasping some of the POSIX compliance coding is a tad different to 
WinAPI and Direct3D ;)

I appreciate any help I can get on this,

    Thanks in advance,
        Dave Smith



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3DC453E9.5040500>