Files
mercury/tests/par_conj/thread_barrier.exp
Peter Wang f6080ebf93 Prevent multi-threaded programs from terminating as soon as the main thread
Branches: main

Prevent multi-threaded programs from terminating as soon as the main thread
terminates, i.e. the process should not terminate until all threads started by
thread.spawn/3 terminate.

This is done by maintaining a a global count of the number of threads started
by thread.spawn.  In low-level C grades the main context will suspend if it
reaches the global_success label and finds there are other contexts still
outstanding.  The last context to terminate then reschedules the main context
to resume.

Similarly, in high-level C grades the main thread waits on a condition
variable, which is signalled by the last thread to terminate.

library/thread.m:
runtime/mercury_context.c:
runtime/mercury_thread.c:
runtime/mercury_thread.h:
runtime/mercury_wrapper.c:
	As above.

	Add some extra assertions related to this.

tests/par_conj/Mmakefile:
tests/par_conj/thread_barrier.exp:
tests/par_conj/thread_barrier.m:
	Add test case

NEWS:
	Announce the change.
2007-05-01 01:13:58 +00:00

12 lines
55 B
Plaintext

loop
loop
loop
loop
loop
loop
loop
loop
loop
loop
fin.