Hi,
I was looking over the service loop section and the pseudo-code in
particular. The pseudo code in the spec is as follows:
int SceMi::ServiceLoop(
SceMiServiceLoopHandler g, void* context, SceMiEC* ec)
{
bool exit_service_loop = false;
int service_request_count = 0;
while( input messages pending )
Send them to HDL side.
while( exit_service_loop == false ) {
if( input ready notifications pending ){
Dispatch input ready callback;
service_request_count++;
if( g != NULL && g(context, 1) == 0 )
exit_service_loop = true;
}
else if( output messages pending ){
Dispatch message to appropriate receive callback.
service_request_count++;
if (g != NULL && !g(context, 1))
exit_service_loop = true;
}
// if( g is not specified ) We kick out of the loop.
// else we stay in as long as g returns non-zero.
else if (g == NULL || g(context, 0) == 0)
exit_service_loop = true;
}
return service_request_count;
}
As I was looking at it I started wondering why the loop over input
messages is outside of the control of the g() function. Basically
I am wondering why the pesudo-code couldn't be this instead:
int SceMi::ServiceLoop(
SceMiServiceLoopHandler g, void* context, SceMiEC* ec)
{
bool exit_service_loop = false;
int service_request_count = 0;
// Outer loop over exit_service_loop.
while ( exit_service_loop == false) {
while( input messages pending )
Send them to HDL side.
while( exit_service_loop == false ) {
if( input ready notifications pending ){
Dispatch input ready callback;
service_request_count++;
if( g != NULL && g(context, 1) == 0 )
exit_service_loop = true;
}
else if( output messages pending ){
Dispatch message to appropriate receive callback.
service_request_count++;
if (g != NULL && !g(context, 1))
exit_service_loop = true;
}
// if( g is not specified ) We kick out of the loop.
// else we stay in as long as g returns non-zero.
else if (g == NULL || g(context, 0) == 0)
exit_service_loop = true;
}
} // End of outer loop on exit_service_loop.
return service_request_count;
}
The advantage of this version of ServiceLoop() is that the user can
provide a g() function that returns 1 until some termination
condition and then one invocation of ServiceLoop() will take of
running the show. With the version that is currently in the spec
the application will need to add a loop external to ServiceLoop() to
do the same thing. What were the choices and reasons that lead to
the current specification? What if any problems are there with the
second version above?
Thanks,
Per
-- Per Bojsen Email: <bojsen@zaiqtech.com> Zaiq Technologies, Inc. WWW: http://www.zaiqtech.com 78 Dragon Ct. Tel: 781 721 8229 Woburn, MA 01801 Fax: 781 932 7488Received on Thu Oct 28 08:39:45 2004
This archive was generated by hypermail 2.1.8 : Thu Oct 28 2004 - 08:40:02 PDT