IPC Implementation

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Reza

IPC Implementation

Post by Reza »

Hi,

We're working on Xeros (= Xinu - source) and
we have to implement an IPC system at UBC.
Note that this is a school project and I'm not
looking for an answer, but rather hints and
advice.

As a background, syscreate, sysyield, sysstop,
sysgetpid, and sysputs have been implemented and
are working (i.e. we have a working dispatcher &
context switcher). I'm responsible to implement
the IPC and I need to find out how it is generally
done. Our messaging system is direct and
synchronous. Here is my current implementation:

1) A process makes a send() calls to another
process:

1.a) the other process is already RECV_BLOCKED
because it has made a recv() call before. If
appropiate, receive the message and ready() both
processes.

1.b) the other process is not RECV_BLOCKED. Add the
sending process to the message queue of this
process. Block the sending process.

2) A process make a recv() call:

2.a) the process makes recv(-1,...) call. In this
case, if there are processes in the message queue
waiting, recv from head of queue, otherwise Block

2.b) the process make recv(pid,...) call. If
process pid is already SEND_BLOCKED, recv message,
otherwise RECV_BLOCK

Does this seem alright? any advice (I'm aware of
indirect [mailbox] communication, but we have
to implement this.

Now, assuming this is correct, how do I actually
pass around the message? I was thinking the
following:

1) Since we have pointer to buffer, copy this
pointer from sending to receiving process.
Basically, the receiving process gains access
to pcb of the sending process. Bad?

2) Copy the buffer into kernel space, then copy
it from kernel space to receiving process. Not
efficient? (too many buffers?)

3) kernel allocates buffer for pcb (pcb has an
void *buffer entry). During communication, the
kernel copies the data from sending process to
this buffer. Not very memory efficient, however
processes are protected.

That's all I can think of. Any advice would be
highly appreciated.

Thanks,
Reza
Post Reply