Clock generator task - forever statement makes the simulator hang

Could you please share a place where you call this clock_gen task?
I see that inside it uses fork ... join which blocks execution until all nested threads are completed and since forever never ends by definition this fork ... join will never release execution. So I suspect that the hang might be caused by this.