You could do worse than Mach ports

Matthew Dillon dillon at apollo.backplane.com
Fri Jul 18 10:34:42 PDT 2003


:As I understand it mp_SendMsg is a function pointer in the message port
:structure. It gets filled in when the port is created.
:

    Precisely.  mp_SendMsg() is controlled by the target port and thus is
    responsible for any frontend optimizations and conversions, including
    chaining.  mp_SendMsg is the 'agent' for the target port.

    This leads to all sorts of cool possibilities.  Inserting a shim
    becomes very easy, you would provide your own port that hides the
    real one and then you would do your own frontend processing.  For
    example:

    struct myport {
	MsgPort		port;
	MsgPort		*realport;
    }t;

    ...initialization of port...
    myport->port.mp_SendMsg = myfunc;
    myport->realport = originalport;

    And then:

    int
    myfunc(struct myport *port, Msg *msg)
    {
	if (message is something we want to play with) {
		...
	}
	/* else fall through to original port */
	return(port->realport->mp_SendMsg(port->realport, msg));
    }

    The port agent would be responsible for all sorts of things.  For
    example, in the kernel on a port representing entry into the TCP stack
    the port agent would be responsible for partitioning the work amoungst
    available TCP stack worker threads and forwarding the message
    appropriately.

					-Matt
					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>





More information about the Kernel mailing list