1 /* Copyright (c) 2016. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 /* This test ensures that the used semaphores are not garbage-collected while we still use it.
7 * This was reported as bug #19893 on gforge.
12 import org.simgrid.msg.*;
13 import org.simgrid.msg.Process;
14 import org.simgrid.trace.Trace;
16 import java.util.ArrayList;
17 import java.util.List;
18 import java.util.Random;
20 class SemCreator extends Process {
23 SemCreator(Host h, String n){
27 public void main(String[] args) throws MsgException{
29 Msg.info("Creating 50 new Semaphores, yielding and triggering a GC after each");
30 for(j = 1; j <= 50; j++) {
31 sem = new Semaphore(0);
35 Msg.info("It worked, we survived. The test is passed.");
40 public class SemaphoreGC {
41 public static void main(String[] args) throws Exception {
44 if (args.length < 1) {
45 Msg.info("Usage: java -cp simgrid.jar:. semaphore.SemaphoreGC <deployment.xml>");
48 Msg.createEnvironment(args[0]);
50 Host[] hosts = Host.all();
51 new SemCreator(hosts[0], "SemCreator").start();