Shared memory and IPC
David Allan Finch
david.allan at finch.org
Wed Sep 5 18:25:44 GMT 2001
Luke Kenneth Casson Leighton wrote:
> does anyone else know how this could be done?
The weird thing about this is I was only talking about this
out loud in the office the other day. I was thinking about
the way the MS had moved there GUI module into the
kernel in NT4 and wonder if we could do the same but
better with X. Basically I wondered if X could be mapped
into a standard area of the address space of an application
in the same way the the Kernel is. Hence you could have
System Mode, GUI Mode, and User Mode. Is the OS
supported this you could get the best of both worlds.
The crash resistance of a User Mode GUI with the
speed of a System Mode one. Anyway it was a thought :-)
The simple answer to the question is, no I don't know
but it would be intresting if you could, wouldn't it :-)
The other idea I have basically involves the use of
special mallocs.
void* create_new_context( int key );
create a set of shared pages
void bind_key( void* context, int key, void* ptr );
map a key to a specific point so it can be looked up
void* lookup_ptr( void* context, int key );
look up the ptr
void malloc_space_and_ref( void* context, void** ptr, size_t len );
create a movable data block and remember the pointers
location so it can be changed
void* malloc_space( void* context, size_t len );
create a normal data block
void free_space( void* context, void* ptr );
remove the data block from the context
void pass_context( void* context );
remove the write premisions from the pages in this server,
so the if we reference the pages we get a segv
void* accept_context( int key );
modify any registered pointed to take into account
the current apps address space and set pages as
writable.
ie a simple example
----8<-------
// server A
const int data_block_key = 0x00000001;
const int string_key = 0x00000002;
void* context = create_new_context( data_block_key );
char* ptr;
char* ptr = (char*)malloc_space( context, strlen(teststr)+1 );
strcpy( ptr, teststr );
bind_key( context, string_key, ptr );
pass_context( context );
--8<-------
when server B accept the context the pointers that have been
registered with malloc_space_and_ref and bind_key are
corrected to the new address space.
-----8<------
// server B
const int data_block_key = 0x00000001;
const int string_key = 0x00000002;
void* context = accept_context( data_block_key );
char* str = (char*)lookup_ptr( context, string_key );
---8<-----
I am not sure if this is all possible and I certainly have
not thought this all the way thought yet :-)
--
/ The whole history of this invention has been a struggle
/\|/\ against time - Charles Babbage 1837 on the Analytical Engine
| K | All Hail Discordia - Burn all Orange Books!
\___/ david.allan at finch.org - http://www.ironfort.com
More information about the samba-technical
mailing list