In reply to tpan:
Can you post more code how clock is initialized and task is called etc? The below code seems to be working fine.
module tb;
bit clk =0;
initial repeat (10) begin
#2 clk =!clk;
end
task run();
$display ("Starting sequence");
repeat (10) begin
@(posedge clk);
$display("Time is %t", $realtime());
end
endtask
initial begin
run();
end
endmodule