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;
15 class SemCreator extends Process {
18 SemCreator(Host h, String n){
22 public void main(String[] args) throws MsgException{
24 Msg.info("Creating 50 new Semaphores, yielding and triggering a GC after each");
25 for(j = 1; j <= 50; j++) {
26 sem = new Semaphore(0);
30 Msg.info("It worked, we survived. The test is passed.");
34 public class SemaphoreGC {
35 private SemaphoreGC() {
36 throw new IllegalAccessError("Utility class");
39 public static void main(String[] args) throws Exception {
41 if (args.length < 1) {
42 Msg.info("Usage: java -cp simgrid.jar:. semaphore.SemaphoreGC <deployment.xml>");
45 Msg.createEnvironment(args[0]);
47 new SemCreator(Host.getByName("Fafard"), "SemCreator").start();