[Xorp-hackers] waiting for a callback return

Orion Hodson oho at acm.org
Tue Jul 1 16:11:28 PDT 2008


XORP processes use a single-threaded event driven model (and  
implicitly process level parallelism). A loop like the one below can  
therefore never exit because the execution path never falls back into  
the event loop dispatcher. The event loop dispatcher handles I/O,  
timers, etc, and is crucial to the operation of a XORP process.

The correct way to achieve the desired effect here is to have the  
callback execute the code that would have happened after the while  
loop below.

A model that XORP could adopt that would allow code like the example  
is Max Krohn's Tame framework:

	http://www.okws.org/doku.php?id=sfslite:tame2

which hides the execution path tearing that is inherent in traditional  
event based coding from the programmer.

- Orion



On Jul 1, 2008, at 11:50 AM, Selçuk Cevher wrote:

> Hi All,
>
> I want to call an xrl method of a process X in the middle of a  
> function defined in some other process Y.
>
> The callback function defined in Y which processes the values  
> returned by X simply sets a boolean variable VAR to TRUE if the  
> value of XrlError object is OKAY.
>
> Below is how I called the xrl method of process X in Y, and wait for  
> the callback to return:
>
>             send_request(argument_list);
>
>             while(!VAR)
>             {
>                 // Do nothing
>             }
>
>             //  When VAR becomes true, do something
>
> where send_request(argument_list) is a local function in Y which  
> calls the xrl method in the client interface of process X till the  
> request has been successfully sent (As expected, it also sends  
> across the name of the callback function in Y).
>
> VAR is set to TRUE when the callback in Y is called with an argument  
> of XrlError::OKAY.
>
> However, waiting in a while loop for VAR to become TRUE through the  
> callback in Y even prevents the xrl_method handler in process X from  
> being called. Hence, the while loop above turns into an infinite  
> loop since VAR will never be set to TRUE by the callback in Y.
>
> What is the proper way other than a while loop like above for  
> waiting for VAR to become true ?
>
> Thanks,
> Selcuk
> _______________________________________________
> Xorp-hackers mailing list
> Xorp-hackers at icir.org
> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers




More information about the Xorp-hackers mailing list