l4-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Viengoos IPC


From: James Collier
Subject: Viengoos IPC
Date: Sun, 28 Jun 2009 00:11:40 +1000

Hello everyone,
This is my first post to any GNU mailing list. Finally I have some time
to play around with Viengoos. 
I've been trying to work out message passing / IPC.
I'm trying to achieve something like what Neal wrote as example code for
GNU Mach IPC [1] using viengoos' vg_ipc* interface.
What I'm trying to accomplish in the following code is an ipc send
operation from the main() thread and an ipc receive operation from the
hello_server thread. i.e. enqueue a messenger on hello_servers
messenger, then dequeue it from hello_server.
I've looked over some stuff in libhurd-mm/, hurd/ and libvingoos/ and
this is what I've come up with:

<code>
/* struct messenger appears in the kernel headers, how is it
initialised? */
vg_messenger_t client_msnger;
/* GLOBAL */ vg_messenger_t receive;
/* used by the server thread. Global so that vg_ipc* in this thread can
access it, does it need to? */

char* string = "hello";
/* Create the server thread */
pthread_t srvr;
pthread_create(&srvr, NULL, (void*) &hello_server, &client_msnger);

/* Allocate a message buffer
* -- Can hurd_message_buffer_alloc() help here?
* Is the following the correct/expected method?
*/
struct vg_message *msg = malloc(PAGESIZE);
vg_message_clear(msg);
/* I'm not really understanding capabilities here, from the reference
* manual: "capability addresses are interpreted as the
* lo-cation of the capabilities to send". Does this mean I need a
* capability referencing the data I want to send (In this case
* char* string)?
* How do I get this capability?
*/

/* Now this message buffer needs to be associated with a messenger */

/* Send the message
* VG_IPC_SEND: Do a send phase
* VG_IPC_SEND_ACTIVATE: Keep giong once the message is transfered
* VG_IPC_SEND_SET_THREAD_TO_CALLER: Is this required? When should it be
* used?
* VG_IPC_SEND_SET_ASROOT_TO_CALLERS: Is this required? When should 
* it be used?
*/
vg_ipc(VG_IPC_SEND | VG_IPC_SEND_ACTIVATE |
        VG_IPC_SEND_SET_THREAD_TO_CALLER |
        VG_IPC_SEND_SET_ASROOT_TO_CALLERS,
        VG_ADDR_VOID, VG_ADDR_VOID, VG_ADDR_VOID, 
        VG_ADDR_VOID, receive, client_msnger, VG_PTR_TO_ADDR(msg));

/* Free the message buffer
* From above: hurd_message_buffer_free()
*/
free(msg);


void
hello_server()
{
struct vg_message *msg = malloc(PAGESIZE);
vg_message_clear(msg);

/* Is __hurd_startup_data->activity valid for this thread? */
vg_ipc(VG_IPC_RECEIVE | VG_IPC_RECEIVE_ACTIVATE |
        VG_IPC_RECEIVE_SET_THREAD_TO_CALLER |
        VG_IPC_RECEIVE_SET_ASROOT_TO_CALLERS,
        VG_ADDR_VOID, recieve, VG_PTR_TO_ADDR(msg), VG_ADDR_VOID,
        VG_ADDR_VOID, VG_ADDR_VOID, VG_ADDR_VOID);

pthread_exit(NULL);
}
</code>

Apologies for the volume of the email and number of questions. The main
ones that I'm interested in at this stage are capabilities and how they
designate an object (e.g. a message buffer (struct vg_message)). Also
how to properly enqueue and dequeue a message between threads.
I expect I am thinking about the whole show incorrectly so thanks in
advance for any corrections.


[1] - ``Hello world à la mach ipc'':
http://walfield.org/pub/people/neal/papers/hurd-misc/ipc-hello.c

IRC: jColl
-- 
James Collier <address@hidden>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]