Jan Atle Ramsli <[EMAIL PROTECTED]> writes:
> The first thing I am going to do when I figure out what this function
> does, is write my understanding down above the function header.
It is documented in the manual at (hurd)RPC Management:
- Funktion: void ports_manage_port_operations_multithread
(struct port_bucket *BUCKET, ports_demuxer_type DEMUXER,
int THREAD_TIMEOUT, int GLOBAL_TIMEOUT, void (*HOOK) (void))
Begin handling operations for the ports in BUCKET, calling DEMUXER
for each incoming message. Return if GLOBAL_TIMEOUT is nonzero
and no messages have been received for GLOBAL_TIMEOUT
milliseconds. Create threads as necessary to handle incoming
messages so that no port is starved because of sluggishness on
another port. If THREAD_TIMEOUT is nonzero, then individual
threads will die off if they handle no incoming messages for
LOCAL_TIMEOUT milliseconds. If non-null, HOOK will be called in
each new thread immediately after it is created.
(I wonder where that "k" came from.)
If you are going to document the function better, I think you
should extend the description in the manual (adding introductory
nodes if necessary) and include in the source code a comment
pointing to the manual.
> And why on earth is a function declared inside another
> function?
I guess only Thomas Bushnell, BSG can answer that.
> It looks like Pascal ..
Or Lisp, perhaps.
> And couldn't some of those parameters be grouped together in a
> struct/union, so that only the address could be passed?
Why would that be useful?
> And how often is this function called?
Once per server, I think.
> while(err != MACH_RCV_TIMED_OUT);
Although this looks like an infinite loop, it is actually the end
of a do-while statement.
Personally I prefer having braces in all do-while statements so
that the while is clearly bound to something above it:
do {
err = mach_msg_server_timeout (internal_demuxer, 0, bucket->portset,
timeout ? MACH_RCV_TIMEOUT : 0,
timeout);
} while (err != MACH_RCV_TIMED_OUT);
But the GNU Coding Standards say that braces should have their
own lines, which kind of defeats the idea.
> suggestion: a) Move ';' to line below, so we can see it.
I once read about an interpreted C-like language which didn't
allow empty statements like ";" -- programmers had to use an
empty block "{}" instead. IMHO it wouldn't hurt to do that in
real C too.
> one for interupt time processing (this one should probably be in the
> kernel)
> and one for task time processing (this one only sucks on the queues that
> the interrupt-time part has filled up, so it shouldn't be in the kernel,
> should it?)
Sounds nice. Who will code that? ;-)