mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-22 04:43:53 +00:00
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.
12 lines
55 B
Plaintext
12 lines
55 B
Plaintext
loop
|
|
loop
|
|
loop
|
|
loop
|
|
loop
|
|
loop
|
|
loop
|
|
loop
|
|
loop
|
|
loop
|
|
fin.
|