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
IPC Implementation
RE:IPC Implementation
>On 2002-02-27 11:55:46, Reza wrote:
>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.
>
[snip]
The dispatcher needs to differentiate sleeping processes from running/ready ones. I'd implement it with a mutex system (you build the rest on it, or similar to it).
CreateMutex()
Each mutex needs a waiting queue, which begins empty. An owner is needed, mark it as null.
AcquireMutex()
Check if available, return immediately if so. (Marking the caller as owner)
Otherwise, put on queue, go to sleep. The dispatcher does not run this one anymore because it sees it as sleeping.
ReleaseMutex()
Check that attempting to release a non-acquired mutex does not crash and does nothing instead.
If acquired, release by waking the sleeping process that had called Acquired() before (if any), and removing it from the queue. Adjust the owner.
DestroyMutex()
Should not be called if anyone has it acquired, or is sleeping on it. In that case, cleanup as you best see fit.
Does this help?
>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.
>
[snip]
The dispatcher needs to differentiate sleeping processes from running/ready ones. I'd implement it with a mutex system (you build the rest on it, or similar to it).
CreateMutex()
Each mutex needs a waiting queue, which begins empty. An owner is needed, mark it as null.
AcquireMutex()
Check if available, return immediately if so. (Marking the caller as owner)
Otherwise, put on queue, go to sleep. The dispatcher does not run this one anymore because it sees it as sleeping.
ReleaseMutex()
Check that attempting to release a non-acquired mutex does not crash and does nothing instead.
If acquired, release by waking the sleeping process that had called Acquired() before (if any), and removing it from the queue. Adjust the owner.
DestroyMutex()
Should not be called if anyone has it acquired, or is sleeping on it. In that case, cleanup as you best see fit.
Does this help?