# global ggg should be created twice

global ggg
	int I = 111
	sem wait_abc = 0
body ggg()
	process globps  {
		P(wait_abc)
		write("This is globps")
		I = I + 111
		V(wait_abc)
	}

	nap(1000) # make sure "This is globps" doesn't get printed
	write("This is ggg initialisation code")

	final {
		write("ggg : Finalisation code")
	}
end ggg

resource abc(int vmnum, int callnum )
	import ggg
	write(vmnum, callnum, "abc : before `import ggg', I is ", I)
	V(wait_abc)
	nap(1000) # let globps proceed
	P(wait_abc)
	write(vmnum, callnum, "abc : after `import ggg', I is ", I)
end abc

resource main()
	import abc

    process p {   # this process encapsulation caused problem once
	cap vm  mcap1 
	create abc(1, 1) on (mcap1 = create vm())
	write("=====")

	cap vm mcap2 = create vm()
	create abc(1, 2) on  mcap2

	destroy mcap1
	destroy mcap2
    }
end main
