bool Service::checkDependencyWithSwapInHood2(Process* p1, Process* p2)
{

	if(this == p2->getService() ||
     p1->getMachine()->getNeighborhood() == p2->getMachine()->getNeighborhood())
	   return true;


	// check <-

	int n2 = p2->getMachine()->getNeighborhood()->getId();

	// there is no processes from service in n2
	if(number_of_processes_in_neighborhood_[n2] == 0)
	{
	   if(dependsOn(p2->getService()) &&
		  p2->getService()->getNumberOfProcessesInNeighborhood(n2) == 1)
		   return false;
	   for(vector<Service*>::iterator it = services_dependends_.begin(); it != services_dependends_.end(); it++)
		  if((*it)->getNumberOfProcessesInNeighborhood(n2) == 0) return false;
	}

	return true;

}
Esempio n. 2
0
void DynamicTask::dependsOn(const DynamicTaskPtr &that)
{
  if(!that) return;
  JASSERT(that!=this).Text("task cant depend on itself");
  JASSERT(_state==S_NEW || _state==S_REMOTE_NEW)(_state).Text(".dependsOn must be called before enqueue()");
  that->_lock.lock();
  if(that->_state == S_CONTINUED){
    that->_lock.unlock();
    dependsOn(that->_continuation);
  }else if(that->_state != S_COMPLETE){
    that->_dependents.push_back(this);
#ifdef DEBUG
    JASSERT(that->_dependents.back()!=NULL);
#endif
    {
      JLOCKSCOPE(_lock);
      _numPredecessors++;
    }
    that->_lock.unlock();
  }else{
    that->_lock.unlock();
  }
#ifdef VERBOSE
    printf("thread %d: task %p depends on task %p counter: %d\n", pthread_self(), this, that.asPtr(), _numPredecessors);
#endif
}
static bool dependsOn(iterator next, iterator dependee, InstructionSet& visited,
	DependenceMap& savedDependencies)
{
	auto dependence = InstructionPair(next->instruction, dependee->instruction);

	auto savedDependence = savedDependencies.find(dependence);

	if(savedDependence != savedDependencies.end())
	{
		return savedDependence->second;
	}

	if(!visited.insert(next->instruction).second) return false;
	
	if(next == dependee) return true;
	
	for(auto successor : next->successors)
	{
		if(dependsOn(successor, dependee, visited, savedDependencies))
		{
			return true;
		}
		
		savedDependencies.insert(std::make_pair(
			InstructionPair(next->instruction, successor->instruction), true));
	}

	savedDependencies.insert(std::make_pair(
		InstructionPair(next->instruction, dependee->instruction), false));

	return false;
}
Esempio n. 4
0
void IndirectRule::setSource(Rule const &rule)
{
    unsetSource();
    dependsOn(_source = &rule);

    invalidate();
}
Esempio n. 5
0
		bool Predicate::dependsOnAny(const TemplateVarArray& array) const {
			for (const auto& templateVar: array) {
				if (dependsOn(templateVar)) {
					return true;
				}
			}
			return false;
		}
bool Service::checkDependencyWithSwap(Process* p1, Process* p2)
{


	//return checkDependencyWithSwapInHood1(p1, p2) && checkDependencyWithSwapInHood2(p1,p2);

	if(this == p2->getService() ||
     p1->getMachine()->getNeighborhood() == p2->getMachine()->getNeighborhood())
	   return true;

	// check ->

	int n1 = p1->getMachine()->getNeighborhood()->getId();

	// p1 is the only process from service in n1 and it is removed from n1
	if(number_of_processes_in_neighborhood_[n1] == 1 &&
	   p1->getMachine()->getNeighborhood() != p2->getMachine()->getNeighborhood())
	{
		if(p2->getService()->dependsOn(this)) return false;
		for(vector<Service*>::iterator it = services_dependendent_.begin(); it != services_dependendent_.end(); it++)
			if((*it)->getNumberOfProcessesInNeighborhood(n1) > 0)
				return false;
	}


	// check <-

	int n2 = p2->getMachine()->getNeighborhood()->getId();

	// there is no processes from service in n2
	if(number_of_processes_in_neighborhood_[n2] == 0)
	{
	   if(dependsOn(p2->getService()) &&
		  p2->getService()->getNumberOfProcessesInNeighborhood(n2) == 1)
		   return false;
	   for(vector<Service*>::iterator it = services_dependends_.begin(); it != services_dependends_.end(); it++)
		  if((*it)->getNumberOfProcessesInNeighborhood(n2) == 0) return false;
	}

	return true;

}
Esempio n. 7
0
void handleInvokeRequest(RemoteOpHeader *h, Node srv, Stream str)
{
  Stream newstr;
  int argc = h->option2, retc = h->option1, fn = h->status, i;
  Object obj;
  ConcreteType ct = 0;
  RemoteOpHeader replyh;
  int *sp;
  State *state;

  anticipateGC(64 * 1024 + 2 * StreamLength(str));
  TRACE(rinvoke, 3, ("InvokeRequest received"));
  /* figure out who we're invoking on */
  obj = OIDFetch(h->target);

  if (!ISNIL(obj)) {
    ct = CODEPTR(obj->flags);
    TRACE(rinvoke, 4, ("Target is a %.*s, operation name is %.*s[%d]",
		       ct->d.name->d.items, ct->d.name->d.data, 
		       ct->d.opVector->d.data[fn]->d.name->d.items,
		       ct->d.opVector->d.data[fn]->d.name->d.data, argc));
  } else {
    TRACE(rinvoke, 1, ("Invoking %s op %d [%d] -> [%d]", OIDString(h->target),
		       fn, argc, retc));
  }

  if (ISNIL(obj)) {
    /*
     * Invoke came here, but we don't know anything about this object.
     * First find it, then send it the message.
     */
    TRACE(rinvoke, 1, ("Trying to find the object and send it the message"));
    ct = (ConcreteType)doObjectRequest(replyh.sslocation, &h->targetct, ctct);
    obj = createStub(ct, getNodeRecordFromSrv(replyh.sslocation), h->target);

    RewindStream(str);
    newstr = StealStream(str);
    findAndSendTo(h->target, newstr);
  } else if (!RESDNT(obj->flags)) {
    Node newsrv = getLocFromObj(obj);
    /* Invoke came here, but the object is elsewhere */
    /* First check to see if we think the object is where this invoke
       came from */
    if (SameNode(srv, newsrv) || SameNode(myid, newsrv) || SameNode(limbo, newsrv)) {
      TRACE(rinvoke, 1, ("Have stub, but points back.  Forwarding to limbo"));
      RewindStream(str);
      newstr = StealStream(str);
      findAndSendTo(h->target, newstr);
    } else {
      TRACE(rinvoke, 1, ("Forwarding invoke to %s", NodeString(newsrv)));
      if (forwardMsg(newsrv, h, str) < 0) {
	RewindStream(str);
	newstr = StealStream(str);
	findAndSendTo(h->target, newstr);
      }
    }
  } else if (fakeUnavailable && ((random() % 100) < fakeUnavailable)) {
    newstr = StealStream(str);
    sendUnavailableReply(newstr);
  } else {
    OID oid;
    state = newState(obj, ct);
    OIDRemoveAny((Object)state);
    ReadOID(&oid, str);
    OIDInsert(oid, (Object) state);
    for (sp = (int *)state->sb, i = 0 ; i < 2 * retc ; i++) *sp++ = JNIL;
    extractNVars(str, argc, sp, &state->ep, &state->et, srv);
    sp += argc * 2;
    TRACE(rinvoke, 4, ("Doing upcall on a %.*s",
		       CODEPTR(obj->flags)->d.name->d.items, 
		       CODEPTR(obj->flags)->d.name->d.data));
    state->sp = (u32)sp;
    pushBottomAR(state);

    /* set up the interpreter state */
    state->pc = (u32) ct->d.opVector->d.data[fn]->d.code->d.data;
    dependsOn(state, stateFetch(h->ss, h->sslocation), retc);
    makeReady(state);
  }
  inhibit_gc--;
}
Esempio n. 8
0
__svc_soundfx::__svc_soundfx(): __uservice("__svc_soundfx", M__VOLATILE)
{
    dependsOn(&audio);
    dependsOn(&volume);
    setControls(INIT);
}
Esempio n. 9
0
void MUPD::added() {
    dependsOn(con);
    dependsOn(money);
}