In reply to Azmo:
Without more context, it is hard to know. You need to debug interactively to see where it is hanging, or add lots of messages.
Also, you need to be care using disable fork to make sure it only kills the child processes in the fork/join_any above it. Soemtimes that means encapsulating the code above an isolating fork begin.. end join
int clk_period = 0;
// are there any existing child processes of the current thread at this point?
fork begin : isolation_process
repeat (2) begin
clk_period = $time - clk_period;
disable fork; // all children of current process get killed
end : isolation_process