Program: 73122
Project: 73122
Buggy source:
/** 
 * Check the input ports of the container composite actor (if there are any) to see whether they have enough tokens, and return true if they do.  If there are no input ports, then also return true. Otherwise, return false.  Note that this does not call prefire() on the contained actors. <p> This method also implements the functionality of <i>synchronizeToRealTime</i> by waiting for real time to elapse if the parameter value is true.
 * @exception IllegalActionException If port methods throw it.
 * @return true If all of the input ports of the container of thisdirector have enough tokens.
 */
public boolean prefire() throws IllegalActionException {
  if (_prefire) {
    return true;
  }
  _prefire=super.prefire();
  if (!super.prefire()) {
    return false;
  }
  double periodValue=periodValue();
  boolean synchronizeValue=((BooleanToken)synchronizeToRealTime.getToken()).booleanValue();
  if ((periodValue > 0.0) && synchronizeValue) {
    int depth=0;
    try {
synchronized (this) {
        while (true) {
          long elapsedTime=System.currentTimeMillis() - _realStartTime;
          double elapsedTimeInSeconds=elapsedTime / 1000.0;
          double currentTime=getModelTime().getDoubleValue();
          if (currentTime <= elapsedTimeInSeconds) {
            break;
          }
          long timeToWait=(long)((currentTime - elapsedTimeInSeconds) * 1000.0);
          if (_debugging) {
            _debug("String_Node_Str" + timeToWait);
          }
          try {
            if (timeToWait > 0) {
              depth=_workspace.releaseReadPermission();
              wait(timeToWait);
            }
          }
 catch (          InterruptedException ex) {
          }
        }
      }
    }
  finally {
      if (depth > 0) {
        _workspace.reacquireReadPermission(depth);
      }
    }
  }
  if (_periodicDirectorHelper != null && !_periodicDirectorHelper.prefire()) {
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str" + getModelTime() + "String_Node_Str"+ periodValue);
    }
    return false;
  }
  TypedCompositeActor container=((TypedCompositeActor)getContainer());
  Iterator inputPorts=container.inputPortList().iterator();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    if (inputPort instanceof ParameterPort) {
      continue;
    }
    int threshold=DFUtilities.getTokenConsumptionRate(inputPort);
    if (_debugging) {
      _debug("String_Node_Str" + inputPort.getFullName());
      _debug("String_Node_Str" + threshold);
    }
    for (int channel=0; channel < inputPort.getWidth(); channel++) {
      if ((threshold > 0) && !inputPort.hasToken(channel,threshold)) {
        if (_debugging) {
          _debug("String_Node_Str" + inputPort.getFullName() + "String_Node_Str"+ threshold+ "String_Node_Str");
        }
        return false;
      }
    }
  }
  if (_debugging) {
    _debug("String_Node_Str");
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Check the input ports of the container composite actor (if there are any) to see whether they have enough tokens, and return true if they do.  If there are no input ports, then also return true. Otherwise, return false.  Note that this does not call prefire() on the contained actors. <p> This method also implements the functionality of <i>synchronizeToRealTime</i> by waiting for real time to elapse if the parameter value is true.
 * @exception IllegalActionException If port methods throw it.
 * @return true If all of the input ports of the container of thisdirector have enough tokens.
 */
public boolean prefire() throws IllegalActionException {
  if (_resourceScheduling && _prefire) {
    return true;
  }
  _prefire=super.prefire();
  if (!_prefire) {
    return false;
  }
  double periodValue=periodValue();
  boolean synchronizeValue=((BooleanToken)synchronizeToRealTime.getToken()).booleanValue();
  if ((periodValue > 0.0) && synchronizeValue) {
    int depth=0;
    try {
synchronized (this) {
        while (true) {
          long elapsedTime=System.currentTimeMillis() - _realStartTime;
          double elapsedTimeInSeconds=elapsedTime / 1000.0;
          double currentTime=getModelTime().getDoubleValue();
          if (currentTime <= elapsedTimeInSeconds) {
            break;
          }
          long timeToWait=(long)((currentTime - elapsedTimeInSeconds) * 1000.0);
          if (_debugging) {
            _debug("String_Node_Str" + timeToWait);
          }
          try {
            if (timeToWait > 0) {
              depth=_workspace.releaseReadPermission();
              wait(timeToWait);
            }
          }
 catch (          InterruptedException ex) {
          }
        }
      }
    }
  finally {
      if (depth > 0) {
        _workspace.reacquireReadPermission(depth);
      }
    }
  }
  if (_periodicDirectorHelper != null && !_periodicDirectorHelper.prefire()) {
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str" + getModelTime() + "String_Node_Str"+ periodValue);
    }
    return false;
  }
  TypedCompositeActor container=((TypedCompositeActor)getContainer());
  Iterator inputPorts=container.inputPortList().iterator();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    if (inputPort instanceof ParameterPort) {
      continue;
    }
    int threshold=DFUtilities.getTokenConsumptionRate(inputPort);
    if (_debugging) {
      _debug("String_Node_Str" + inputPort.getFullName());
      _debug("String_Node_Str" + threshold);
    }
    for (int channel=0; channel < inputPort.getWidth(); channel++) {
      if ((threshold > 0) && !inputPort.hasToken(channel,threshold)) {
        if (_debugging) {
          _debug("String_Node_Str" + inputPort.getFullName() + "String_Node_Str"+ threshold+ "String_Node_Str");
        }
        return false;
      }
    }
  }
  if (_debugging) {
    _debug("String_Node_Str");
  }
  return true;
}