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.*;
14 class SemCreator extends Process {
17 SemCreator(Host h, String n){
21 public void main(String[] args) throws MsgException{
23 Msg.info("Creating 50 new Semaphores, yielding and triggering a GC after each");
24 for(j = 1; j <= 50; j++) {
25 sem = new Semaphore(0);
29 Msg.info("It worked, we survived. The test is passed.");
33 public class SemaphoreGC {
34 public static void main(String[] args) throws Exception {
36 if (args.length < 1) {
37 Msg.info("Usage: java -cp simgrid.jar:. semaphore.SemaphoreGC <deployment.xml>");
40 Msg.createEnvironment(args[0]);
42 Host[] hosts = Host.all();
43 new SemCreator(hosts[0], "SemCreator").start();