In the example below, the function task get_first spawns
three versions of a function task that wait for a particular device (1, 7, or 13). The function task wait_device waits
for a particular device to become ready and then returns the device’s address.
When the first device becomes available, the get_first function task shall
resume execution and proceed to kill the outstanding wait_device processes.
function task integer
get_first( output int adr );
fork
get_first = wait_device( 1, adr
);
get_first = wait_device( 7, adr
);
get_first = wait_device( 13, adr
);
join_any
disable
fork;
endfunction endtask