Example #1
0
Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Anope::string &desc, const Anope::string &ssid, bool jupe) : name(sname), hops(shops), description(desc), sid(ssid), uplink(up), users(0)
{
	syncing = true;
	juped = jupe;
	quitting = false;

	Servers::ByName[sname] = this;
	if (!ssid.empty())
		Servers::ByID[ssid] = this;

	Log(this, "connect") << "has connected to the network (uplinked to " << (this->uplink ? this->uplink->GetName() : "no uplink") << ")";

	/* Add this server to our uplinks leaf list */
	if (this->uplink)
	{
		this->uplink->AddLink(this);

		/* Check to be sure this isn't a juped server */
		if (Me == this->uplink && !juped)
			Burst();
	}

	EventManager::Get()->Dispatch(&Event::NewServer::OnNewServer, this);
}
Example #2
0
void System::initEQ(double cpus, double ios, double context, double mix, double freq)
{
    idleCPU = cpus;
    maxCPU = cpus;
    numIO = ios;
    contextSwitch = context;
    taskMix = mix;
    frequencyOfTasks = freq;

    endTime = 2000;
    int numberOfTasks = endTime / freq;

    IOReadySet.resize(numIO);
    idleDevices.resize(numIO);
    stats.ioUtilizations.resize(numIO);

    for(int i = 0; i < numIO; ++i){
        idleDevices.at(i) = true;
        IOReadySet.at(i) = std::make_shared<FIFO>();
    }

    int t = 0;
    std::uniform_int_distribution<int> distribution(1, 30);
    auto randomInt = std::bind(distribution, generation);

    std::uniform_int_distribution<int> distribution0_100(1, 100);

    std::normal_distribution<double> distributionSmall(3,1);
    auto randomRealSmall = std::bind (distributionSmall, generation);
    std::normal_distribution<double> distributionLarge(7,2);
    auto randomRealLarge = std::bind (distributionLarge, generation);


    for(int i = 0; i < numberOfTasks; ++i)
    {

        int whichSet = distribution0_100(generation);
        int numBurst = randomInt() % 12 + 2;
        int device  = randomInt() % (int)numIO;
        std::vector<Burst> b;

        if(whichSet >= (taskMix * 100) ){ //CPU bound
            b.push_back(Burst(randomRealLarge(), -1));
            for(int i =0; i < numBurst; ++i){
                if(device >=0){
                    double burstTime = randomRealSmall();
                    b.push_back(Burst(burstTime, device));
                    device = -1;
                }
                else{
                    double burstTime = randomRealLarge();
                    b.push_back(Burst(burstTime, device));
                    device = randomInt() % (int)numIO;
                }
            }
            b.push_back(Burst(randomRealLarge(), -1));
        }
        else{ // IOBound
            b.push_back(Burst(randomRealSmall(), -1));
            for(int i =0; i < numBurst; ++i){
                if(device >=0){
                    double burstTime = randomRealLarge();
                    b.push_back(Burst(burstTime, device));
                    device = -1;
                }
                else{
                    double burstTime = randomRealSmall();
                    b.push_back(Burst(burstTime, device));
                    device = randomInt() % (int)numIO;
                }
            }
            b.push_back(Burst(randomRealSmall(), -1));
        }

        //make a task, then an StartTask event, then an Event and push it into eq
        auto task = std::make_shared<Task>(t,b);
        auto e = std::make_shared <StartTask> ( task );
        eq.push( std::dynamic_pointer_cast<Event> (e )  );
        t += (frequencyOfTasks + randomInt() % 3 );
        }
    eq.push( std::dynamic_pointer_cast<Event> (std::make_shared <EndSim> (endTime) ) );
}