Beispiel #1
0
static bool dispatcher_list_dispatch(const DispatcherList* list,
                                     DBusConnection*       connection,
                                     DBusMessage*          msg)
{
  bool          dispatched = false;
  int           msg_type   = dbus_message_get_type(msg);
  Dispatcher*   d          = 0;
  const GSList* i;
  for (i = list->dispatchers; i; i = g_slist_next(i)) {
    d = i->data;
    if (d->can_dispatch(d, msg)) {
        d->dispatch(d, connection, msg);
        dispatched = true;

        /* Method calls should have only one handler.
	 * Stop after suitable one has been found. */
        if( msg_type == DBUS_MESSAGE_TYPE_METHOD_CALL )
           break;
    }
  }

  return dispatched;
}
Beispiel #2
0
std::unique_ptr<RenewTraits::Response> RenewTraits::dispatch(Dispatcher & dispatcher, const Request & request, const RequestIdentifier & identifier) {
	return dispatcher.dispatch(request, identifier);
}
Beispiel #3
0
std::unique_ptr<ProbeTraits::Response> ProbeTraits::dispatch(Dispatcher & dispatcher, const Request & request) {
	return dispatcher.dispatch(request);
}
Beispiel #4
0
std::unique_ptr<UnsubscribeTraits::Response> UnsubscribeTraits::dispatch(Dispatcher & dispatcher, const Request & request, const RequestIdentifier & identifier) {
	return dispatcher.dispatch(request, identifier);
}
Beispiel #5
0
string Bio::dispatch(const Dispatcher& d) const {
    return d.dispatch(*this);
}
Beispiel #6
0
string UserInfo::dispatch(const Dispatcher& d) const {
        return d.dispatch(*this);
}
Beispiel #7
0
/**
 * Driver Thread
 * Runs the schedulers and dispatcher.
 */
void* driver_thread(void*) 
{
	Loader loader;
	ProcessList* pList = 0;
	LongTermScheduler* lts = 0;
	ShortTermScheduler* sts = 0;
	Dispatcher* dsp = 0;
	pthread_t cpuThread;
	bool done = false;
	unsigned int ltsCnt = 0;

	disk = new Memory(2048);
	ram = new Memory(1024);

	loader = Loader("data/datafile2.txt");
	pList = loader.loadDisk(disk);

	cpu = new Cpu(ram, pList);

	lts = new LongTermScheduler(disk, ram, pList); // TODO: CPU instead of pList?
	sts = new ShortTermScheduler(cpu);
	dsp = new Dispatcher(cpu, ram);

	if(DEBUGGING) {
		cpu->setDebug(true);
		lts->setDebug(true);
		sts->setDebug(true);
		dsp->setDebug(true);
	}

	// Run the schedulers once at the start
	lts->schedule();
	sts->rebuildQueue();
	dsp->dispatch();
	ltsCnt = 1;

	// Spawn CPU thread. 
	pthread_create(&cpuThread, 0, &cpu_thread, 0);

	do
	{
		done = true;

		// Wait for interrupt. 
		pthread_mutex_lock(&mux);
		pthread_cond_wait(&interrupt, &mux);

		// LTS only runs every so often.
		if(ltsCnt % 4 == 0) {
			lts->schedule();
		}
		ltsCnt++;

		// STS, Dispatcher
		sts->rebuildQueue();
		dsp->dispatch();

		// See if we can stop. 
		for(unsigned int i = 0; i < pList->all.size(); i++) {
			if(pList->all[i]->state != STATE_TERM_UNLOADED) {
				done = false;
				break;
			}
		}

		pthread_mutex_unlock(&mux);
	} 
	while(!done);

	pthread_join(cpuThread, 0);

	// Final Report
	cout << "\nFinal PCB Values:\n";
	cout << "=================\n";
	pList->printJobs();
	cout << endl;

	cout << "Writing memories to disk...\n";
	ram->writeDisk("ram.txt");
	disk->writeDisk("disk.txt");

	return 0;
}