Beispiel #1
0
static
int play(struct audio_play *play)
{
  update_stats(play->stats, play->nsamples, play->samples[0]);
  if (play->samples[1])
    update_stats(play->stats, play->nsamples, play->samples[1]);

  return 0;
}
Beispiel #2
0
int sent_xmsg_stats(User *usr, XMsg *x, char *name) {
	switch(x->type) {
		case XMSG_X:
			usr->xsent++;
			user_dirty(usr, "xsent");
			update_stats(usr);
			inc_stats(STATS_XSENT);
			break;

		case XMSG_EMOTE:
			usr->esent++;
			user_dirty(usr, "esent");
			update_stats(usr);
			inc_stats(STATS_ESENT);
			break;

		case XMSG_FEELING:
			usr->fsent++;
			user_dirty(usr, "fsent");
			update_stats(usr);
			inc_stats(STATS_FSENT);
			break;

		case XMSG_QUESTION:
			usr->qsent++;
			user_dirty(usr, "qsent");
			update_stats(usr);
			inc_stats(STATS_QSENT);
			break;

		case XMSG_ANSWER:
			usr->qansw++;
			user_dirty(usr, "qansw");
			update_stats(usr);
			inc_stats(STATS_QANSW);
			break;

		default:
			;
	}
	if (name != NULL) {							/* add to talked_to list */
		if (usr->talked_to.len <= 0)
			gstrcpy(&(usr->talked_to), name);
		else {
			if (!cstrfind(usr->talked_to.str, name, ',')) {
				gstrcat(&(usr->talked_to), ",");
				gstrcat(&(usr->talked_to), name);
			}
		}
	}
	return 0;
}
Beispiel #3
0
void *worker(void *arg)
{
	struct lockinfo *l = (struct lockinfo *)arg;
	int burn_count = 0;
	pthread_t tid = pthread_self();
	size_t pagesize = getpagesize();
	char *buf = malloc(pagesize);

	if (!buf) {
		perror("malloc");
		exit(1);
	}

	l->tid = tid;
	workers_started = 1;
	smp_mb();

	while(!all_done) {
		l->ops->wait(l);
		if (all_done)
			break;
		burn_count++;
	}
	pthread_mutex_lock(&worklist_mutex);
	total_burns += burn_count;
	if (burn_count < min_burns)
		min_burns = burn_count;
	if (burn_count > max_burns)
		max_burns = burn_count;
	update_stats(&burn_stats, burn_count);
	thread_count--;
	pthread_mutex_unlock(&worklist_mutex);
	return (void *)0;
}
Beispiel #4
0
void TournamentSR::round_finished_set_time(Player *p, GTransportTime *race) {
    /* server side */
    TimesOfPlayer *top = get_times_of_player(p);
    if (top) {
        GTransportTime *tm = new GTransportTime;
        *tm = *race;
        tm->to_net();
        add_state_response(GPCScoreTransportRaw, GTransportTimeLen, tm);
        float diff = race->ms / 1000.0f;

        TimesOfPlayer& first_top = times_of_players[0];
        bool has_entries = first_top.times.size() > 0;
        float best_time = first_top.best;

        update_stats(top, diff);

        if ((has_entries && diff < best_time) || !has_entries) {
            sprintf(buffer, "new record of %s: %.2f", p->get_player_name().c_str(), diff);
            add_msg_response(buffer);
            add_sound_response("round_complete_best");
            if (logger) {
                logger->log(ServerLogger::LogTypeRoundFinished, buffer, p, 0, &diff);
            }
        } else {
            add_sound_response("round_complete");
            if (logger) {
                logger->log(ServerLogger::LogTypeRoundFinished, "round completed", p, 0, &diff);
            }
        }
    }
}
	void feed(buffer_s16_t src, Callback callback) {
		consume_audio_buffer(src);

		if( update_stats(src.count, src.sampling_rate) ) {
			callback(statistics);
		}
	}
void action_t::execute()
{
  if ( sim -> log && ! dual ) 
  {
    log_t::output( sim, "%s performs %s (%.0f)", player -> name(), name(), 
                   player -> resource_current[ player -> primary_resource() ] );
  }

  if ( observer ) *observer = 0;

  player_buff();

  target_debuff( DMG_DIRECT );

  calculate_result();

  consume_resource();

  if ( result_is_hit() )
  {
    calculate_direct_damage();

    if ( direct_dmg > 0 )
    {
      assess_damage( direct_dmg, DMG_DIRECT );
    }
    if ( num_ticks > 0 )
    {
      if ( dot_behavior == DOT_REFRESH )
      {
        current_tick = 0;
        if ( ! ticking ) schedule_tick();
      }
      else
      {
        if ( ticking ) cancel();
        snapshot_haste = haste();
        schedule_tick();
      }
    }
  }
  else
  {
    if ( sim -> log )
    {
      log_t::output( sim, "%s avoids %s (%s)", sim -> target -> name(), name(), util_t::result_type_string( result ) );
      log_t::miss_event( this );
    }
  }

  update_ready();

  if ( ! dual ) update_stats( DMG_DIRECT );

  schedule_travel();

  if ( repeating && ! proc ) schedule_execute();

  if ( harmful ) player -> in_combat = true;
}
/**
 * Send request to peer to start add him to to the set of experimentation nodes
 *
 * @param peer the peer to send to
 */
static void
send_experimentation_request (const struct GNUNET_PeerIdentity *peer)
{
  struct Node *n;
  struct NodeComCtx *e_ctx;
  size_t size;
  size_t c_issuers;

  c_issuers = GNUNET_CONTAINER_multihashmap_size (valid_issuers);
  size = sizeof (struct Experimentation_Request) +
    c_issuers * sizeof (struct GNUNET_CRYPTO_EddsaPublicKey);
  n = GNUNET_new (struct Node);
  n->id = *peer;
  n->timeout_task = GNUNET_SCHEDULER_add_delayed (EXP_RESPONSE_TIMEOUT, &remove_request, n);
  n->capabilities = NONE;

  e_ctx = GNUNET_new (struct NodeComCtx);
  e_ctx->n = n;
  e_ctx->e = NULL;
  e_ctx->size = size;
  e_ctx->notify = &send_experimentation_request_cb;
  e_ctx->notify_cls = n;
  GNUNET_CONTAINER_DLL_insert_tail(n->e_req_head, n->e_req_tail, e_ctx);
  schedule_transmisson (e_ctx);

  GNUNET_assert (GNUNET_OK ==
		 GNUNET_CONTAINER_multipeermap_put (nodes_requested,
						    peer, n,
						    GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
  update_stats (nodes_requested);
}
Beispiel #8
0
int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res)
{
	int full;

	if (static_branch_likely(&psi_disabled))
		return -EOPNOTSUPP;

	update_stats(group);

	for (full = 0; full < 2 - (res == PSI_CPU); full++) {
		unsigned long avg[3];
		u64 total;
		int w;

		for (w = 0; w < 3; w++)
			avg[w] = group->avg[res * 2 + full][w];
		total = div_u64(group->total[res * 2 + full], NSEC_PER_USEC);

		seq_printf(m, "%s avg10=%lu.%02lu avg60=%lu.%02lu avg300=%lu.%02lu total=%llu\n",
			   full ? "full" : "some",
			   LOAD_INT(avg[0]), LOAD_FRAC(avg[0]),
			   LOAD_INT(avg[1]), LOAD_FRAC(avg[1]),
			   LOAD_INT(avg[2]), LOAD_FRAC(avg[2]),
			   total);
	}

	return 0;
}
Beispiel #9
0
static void psi_update_work(struct work_struct *work)
{
	struct delayed_work *dwork;
	struct psi_group *group;
	bool nonidle;

	dwork = to_delayed_work(work);
	group = container_of(dwork, struct psi_group, clock_work);

	/*
	 * If there is task activity, periodically fold the per-cpu
	 * times and feed samples into the running averages. If things
	 * are idle and there is no data to process, stop the clock.
	 * Once restarted, we'll catch up the running averages in one
	 * go - see calc_avgs() and missed_periods.
	 */

	nonidle = update_stats(group);

	if (nonidle) {
		unsigned long delay = 0;
		u64 now;

		now = sched_clock();
		if (group->next_update > now)
			delay = nsecs_to_jiffies(group->next_update - now) + 1;
		schedule_delayed_work(dwork, delay);
	}
}
Beispiel #10
0
static void send_scheduler_task (enum phase_e phase, size_t wid)
{
    size_t tid = user.scheduler_f (phase, wid);

    if (tid == NONE)
    {
	return;
    }

    enum task_type_e task_type = get_task_type (phase, tid, wid);
    size_t	     sid = NONE;

    if (task_type == LOCAL || task_type == LOCAL_SPEC)
    {
	sid = wid;
    }
    else if (task_type == REMOTE || task_type == REMOTE_SPEC)
    {
	sid = find_random_chunk_owner (tid);
    }

    XBT_INFO ("%s %zu assigned to %s %s", (phase==MAP?"map":"reduce"), tid,
	    MSG_host_get_name (config.workers[wid]),
	    task_type_string (task_type));

    send_task (phase, tid, sid, wid);

    update_stats (task_type);
}
Beispiel #11
0
void TournamentSR::score_transport_raw(void *data) {
    GTransportTime *tm = reinterpret_cast<GTransportTime *>(data);
    tm->from_net();
    TimesOfPlayer *top = get_times_of_player(tm->id);
    if (top) {
        update_stats(top, tm->ms / 1000.0f);
    }
}
Beispiel #12
0
void fs_emu_audio_video_sync(int time_ms) {
    for (int i = 0; i < MAX_STREAMS; i++) {
        if (g_streams[i]) {
            unqueue_old_buffers(i);
            update_stats(i, time_ms);
            pid_controller_step(i, time_ms);
        }
    }
}
Beispiel #13
0
void		load_game(void)
{
  update_background();
  update_content();
  collisions();
  update_stats();
  display_content();
  draw();
}
/**
 * Remove experimentation request due to timeout
 *
 * @param cls the related node
 * @param tc scheduler's task context
 */
static void
remove_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  struct Node *n = cls;

  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
	      "Removing request for peer %s due to timeout\n",
	      GNUNET_i2s (&n->id));
  if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (nodes_requested, &n->id))
  {
    GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_remove (nodes_requested, &n->id, n));
    update_stats (nodes_requested);
    GNUNET_CONTAINER_multipeermap_put (nodes_inactive, &n->id, n,
				       GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
    update_stats (nodes_inactive);
  }
  n->timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
Beispiel #15
0
static void *run(void *data)
{
	(void)data; /* unused parameter. silence warning. */
	init_nl();
	raw_sample_buf_init();
	init_realtime();
	set_sample_period(SAMPLE_PERIOD_US);

	struct timespec deadline;
	clock_gettime(CLOCK_MONOTONIC, &deadline);

	int sample_no = 0;
	char *iface = strdup(g_iface);
	struct iface_stats *stats_frame = raw_sample_buf_produce_next();
	snprintf(stats_frame->iface, MAX_IFACE_LEN, "%s", iface);
	stats_frame->sample_period_us = sample_period_us;

	for (;;) {
		update_stats(&(stats_frame->samples[sample_no]), iface,
		             deadline);

		sample_no++;
		sample_no %= SAMPLES_PER_FRAME;

		/* set the iface, samples per period at start of each frame*/
		if (sample_no == 0) {
			pthread_mutex_lock(&g_iface_mutex);
			free(iface);
			iface = strdup(g_iface);

			stats_frame = raw_sample_buf_produce_next();
			snprintf(stats_frame->iface, MAX_IFACE_LEN, "%s",
			         iface);
			pthread_mutex_unlock(&g_iface_mutex);
			stats_frame->sample_period_us = sample_period_us;
			stats_handler(raw_sample_buf_consume_next());
		}

		deadline.tv_nsec += 1000 * sample_period_us;

		/* Normalize the time to account for the second boundary */
		if (deadline.tv_nsec >= 1000000000) {
			deadline.tv_nsec -= 1000000000;
			deadline.tv_sec++;
		}

		clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &deadline,
		                NULL);
	}

	return NULL;
}
NEURON_OUTPUT 
UpdateStats(PARAM_LIST *pParamList)
{
	NEURON_OUTPUT output;

	update_stats(g_number, g_label, g_certainty, g_activation, NL_WIDTH * NL_HEIGHT, g_result);

	g_translate_x = 0;
	g_translate_y = 0;

	output.fval = g_certainty;
	return (output);
}
Beispiel #17
0
void DexesStructure::add_class_no_checks(const MethodRefs& clazz_mrefs,
                                         const FieldRefs& clazz_frefs,
                                         const TypeRefs& clazz_trefs,
                                         DexClass* clazz) {
  always_assert_log(m_classes.count(clazz) == 0,
                    "Can't emit the same class twice: %s!\n", SHOW(clazz));

  auto laclazz = estimate_linear_alloc(clazz);
  m_current_dex.add_class_no_checks(clazz_mrefs, clazz_frefs, clazz_trefs,
                                    laclazz, clazz);
  m_classes.emplace(clazz);
  update_stats(clazz_mrefs, clazz_frefs, clazz);
}
Beispiel #18
0
static struct net_device_stats *el3_get_stats(struct net_device *dev)
{
    struct el3_private *lp = netdev_priv(dev);
    unsigned long flags;
    struct pcmcia_device *link = lp->p_dev;

    if (pcmcia_dev_present(link)) {
	spin_lock_irqsave(&lp->lock, flags);
	update_stats(dev);
	spin_unlock_irqrestore(&lp->lock, flags);
    }
    return &dev->stats;
}
/**
 * Stop the nodes management
 */
void
GED_nodes_stop ()
{
  if (NULL != ch)
  {
  		GNUNET_CORE_disconnect (ch);
  		ch = NULL;
  }

  if (NULL != nodes_requested)
  {
  		GNUNET_CONTAINER_multipeermap_iterate (nodes_requested,
  																					 &cleanup_node,
  																					 nodes_requested);
  		update_stats (nodes_requested);
  		GNUNET_CONTAINER_multipeermap_destroy (nodes_requested);
  		nodes_requested = NULL;
  }

  if (NULL != nodes_active)
  {
  		GNUNET_CONTAINER_multipeermap_iterate (nodes_active,
  																					 &cleanup_node,
  																					 nodes_active);
  		update_stats (nodes_active);
  		GNUNET_CONTAINER_multipeermap_destroy (nodes_active);
  		nodes_active = NULL;
  }

  if (NULL != nodes_inactive)
  {
  		GNUNET_CONTAINER_multipeermap_iterate (nodes_inactive,
  																					 &cleanup_node,
  																					 nodes_inactive);
  		update_stats (nodes_inactive);
  		GNUNET_CONTAINER_multipeermap_destroy (nodes_inactive);
  		nodes_inactive = NULL;
  }
}
NEURON_OUTPUT 
UpdateStats(PARAM_LIST *pParamList)
{
	NEURON_OUTPUT output;
	
	update_stats(g_number, g_label, g_certainty, g_activation, (&char_discr_out)->ww * (&char_discr_out)->wh, g_result);
		
	g_translate_x = 0;
	g_translate_y = 0;

	output.fval = g_certainty;
	return (output);
}
Beispiel #21
0
/*
	Note: User u must be locked
*/
int recv_XMsg(User *u, XMsg *x) {
PList *pl;

	if ((pl = new_PList(x)) == NULL)
		return -1;

	x->refcount++;

	append_PList(&(u->recv_xmsgs), pl);

	switch(x->type) {
		case XMSG_X:
			u->xrecv++;
			user_dirty(u, "xrecv");
			update_stats(u);
			inc_stats(STATS_XRECV);
			break;

		case XMSG_EMOTE:
			u->erecv++;
			user_dirty(u, "erecv");
			update_stats(u);
			inc_stats(STATS_ERECV);
			break;

		case XMSG_FEELING:
			u->frecv++;
			user_dirty(u, "frecv");
			update_stats(u);
			inc_stats(STATS_FRECV);
			break;

		default:
			;
	}
	wakeup(u);
	return 0;
}
static struct net_device_stats *el3_get_stats(struct net_device *dev)
{
    struct el3_private *lp = (struct el3_private *)dev->priv;
    unsigned long flags;
    dev_link_t *link = &lp->link;

    if (DEV_OK(link)) {
	save_flags(flags);
	cli();
	update_stats(dev);
	restore_flags(flags);
    }
    return &lp->stats;
}
Beispiel #23
0
int main()
{
	int studentRec=0;
	int courseRec=0;
	int numberOfResults =0;
	int menuSelector=0;
	int programExiter = 0;
	struct student studData[50];
	struct course corsMat[50];
	struct exam examResult[50];
	struct stats examStats[50];
	printf("%s\n","This program will be used to record information regarding students , Courses and exams.\n");
	/*This is the option menu which runs the program*/
	while(!programExiter){
		printf("%s\n","Please use the following menu to run the program\n1) Add student records\n2) Add courses Information\n3) Input exam results\n4) Calculate course statistics\n5) Remove results if higher grades available\n6) Show Student information\n7) Show Course information\n8) Show statistics\n9) Exit the program");
		scanf("%d",&menuSelector);
		switch(menuSelector){
			/*This adds data stored about students*/
			case 1: input_student_info(studData, &studentRec);
				break;
			/*This adds data stored about courses*/
			case 2: input_course_info(corsMat, &courseRec);
				break;
			/*This is used input information regarding */
			case 3: input_exam_info(examResult, &numberOfResults, corsMat, &courseRec,studData, &studentRec);
				break;
			case 4: update_stats(examStats,corsMat, &courseRec,examResult, &numberOfResults);
				break;
			case 5: 
				break;
			/*This prints the stored records to the consol*/
			case 6: printStudentInformation(studData, &studentRec);
				break;
			/*This Prints all the data stored in exams*/
			case 7:	printCorsInformation(corsMat, &courseRec);
				break;
			case 8: printStatInformation(examStats, &courseRec);
				break;
			case 9: programExiter = 1;
				break;
			default: 
				break;

		}
		
	}
	
	return 0;
}
Beispiel #24
0
long
igb_net_ioctl(struct file *filp,
	 unsigned int cmd, unsigned long arg)
{
	int ret = 0;

	switch (cmd) {
	case SEND_STATS:
		ret = update_stats((struct stats_struct __user *) arg);
		break;
	default:
		ret = -ENOTTY;
	}
	return ret;
}
Beispiel #25
0
/* Hash test: buffer of size byte. Run test n times. */
static void run_test(size_t size, unsigned int n, unsigned int l)
{
	uint64_t t;
	struct statistics stats;
	TEEC_Operation op;
	int n0 = n;

	alloc_shm(size, algo);

	if (!random_in)
		memset((uint8_t *)in_shm.buffer + offset, 0, size);

	memset(&op, 0, sizeof(op));
	op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_PARTIAL_INPUT,
					 TEEC_MEMREF_PARTIAL_OUTPUT,
					 TEEC_VALUE_INPUT, TEEC_NONE);
	op.params[0].memref.parent = &in_shm;
	op.params[0].memref.offset = 0;
	op.params[0].memref.size = size + offset;
	op.params[1].memref.parent = &out_shm;
	op.params[1].memref.offset = 0;
	op.params[1].memref.size = hash_size(algo);
	op.params[2].value.a = l;
	op.params[2].value.b = offset;

	verbose("Starting test: %s, size=%zu bytes, ",
		algo_str(algo), size);
	verbose("random=%s, ", yesno(random_in));
	verbose("unaligned=%s, ", yesno(offset));
	verbose("inner loops=%u, loops=%u, warm-up=%u s\n", l, n, warmup);

	if (warmup)
		do_warmup();

	memset(&stats, 0, sizeof(stats));
	while (n-- > 0) {
		t = run_test_once((uint8_t *)in_shm.buffer + offset, size, &op, l);
		update_stats(&stats, t);
		if (n % (n0/10) == 0)
			vverbose("#");
	}
	vverbose("\n");
	printf("min=%gμs max=%gμs mean=%gμs stddev=%gμs (%gMiB/s)\n",
	       stats.min/1000, stats.max/1000, stats.m/1000,
	       stddev(&stats)/1000, mb_per_sec(size, stats.m));
	free_shm();
}
Beispiel #26
0
bool DexesStructure::add_class_to_current_dex(const MethodRefs& clazz_mrefs,
                                              const FieldRefs& clazz_frefs,
                                              const TypeRefs& clazz_trefs,
                                              DexClass* clazz) {
  always_assert_log(m_classes.count(clazz) == 0,
                    "Can't emit the same class twice!\n", SHOW(clazz));

  if (m_current_dex.add_class_if_fits(clazz_mrefs, clazz_frefs, clazz_trefs,
                                      m_linear_alloc_limit, m_type_refs_limit,
                                      clazz)) {
    update_stats(clazz_mrefs, clazz_frefs, clazz);
    m_classes.emplace(clazz);
    return true;
  }

  return false;
}
/**
 * Set a specific node as active
 *
 * @param n the node
 */
static void
node_make_active (struct Node *n)
{
  int c1;

  GNUNET_CONTAINER_multipeermap_put (nodes_active,
				     &n->id, n, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
  update_stats (nodes_active);
  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
	      _("Added peer `%s' as active node\n"),
	      GNUNET_i2s (&n->id));
  /* Request experiments for this node to start them */
  for (c1 = 0; c1 < n->issuer_count; c1++)
  {
    GED_experiments_get (n, &n->issuer_id[c1], &get_experiments_cb);
  }
}
Beispiel #28
0
void dnet_monitor_stats_update(struct dnet_node *n, const struct dnet_cmd *cmd,
                               const int err, const int cache,
                               const uint32_t size, const unsigned long time) {
	try {
		auto real_monitor = ioremap::monitor::get_monitor(n);
		if (real_monitor) {
			real_monitor->get_statistics().command_counter(cmd->cmd, cmd->trans, err,
								       cache, size, time);
			auto top_stats = real_monitor->get_statistics().get_top_stats();
			if (top_stats) {
				top_stats->update_stats(cmd, size);
			}
		}
	} catch (const std::exception &e) {
		dnet_log(n, DNET_LOG_DEBUG, "monitor: failed to update stats: %s", e.what());
	}
}
Beispiel #29
0
void reveal_coordinate(int x, int y) {
/* Als een cel een mijn bevat, dan is de speler dood*/
if (get_cell(x, y)->is_mine == 1 )
{
    printf("/+/+/+/ MINE EXPLODED /+/+/+/ \n");
    printf("\n");
    dead = 1;
    print_grid();
    printf("Spel wordt afgesloten...\n");


    draw_grid();
    update_stats();
    show_stats();
    sleep(2);
    deallocate_grid(WIDTH, HEIGHT);
    exit(0);
}

/* Als de cel geen mijn is, verander dan zijn staat van covered naar uncovered. */
else {
    // Zet de status van het vakje op UNCOVERED.
    get_cell(x, y)->state = UNCOVERED;

  // Test of het vakje geen naburige mijnen heeft.
  if (get_cell(x, y)->neighbouring_mines == 0)
  {

    // Als het 0 naburige vakjes heeft, moeten al zijn buren bekeken worden of zij een mijn in de buurt hebben.

    for (int i = -1; i < 2; i++) // Begin bij de cel aan de linkse kant (vandaar de -1).
      {
        for (int j = -1; j < 2; j++) // Begin bij de cel aan de rechtse kant.
        {
          if ((x + i) < WIDTH && (x + i)  >= 0 && (y + j) < HEIGHT && (y + j) >= 0) // Controle of een buurcel van de mijn zich niet buiten de randen van het veld bevindt.
          {
            if (get_cell(x + i, y + j)->state == COVERED)
            {
          reveal_coordinate(x + i, y + j); // Recursieve oproep op de naburige cellen.
            }
          }
        }
      }
    }
  }
}
Beispiel #30
0
void stateDRR::handle_departure(int pkt, int src)
{
    update_stats(src);
#ifdef DEBUG
    fprintf(stdout, "[%ld] Dequeue\t %d\ts %d\tp %d\t sz %ld\tserv %ld\tdef %d\n", this->clock,
            this->flows[src].front()->type, this->flows[src].front()->sourceId,
            this->flows[src].front()->packetId, this->flows[src].size(), 
            this->globalStats.totalPackets, this->deficit[src]);
#endif
    this->flows[src].pop();
    this->eventQueue.pop();
#ifdef DEBUG
    if(this->flows[src].size() > 0) {
    cout<<this->clock<<" \t D \t pkt "<<pkt<<" \tsrc "<<src<<endl;
    }
#endif
    
    if(this->currentPackets >= 1) {
        /* When there are multiple packets,must schedule next departure 
         * to follow work-preserving model.
         * Next departure must be from the next immediate active flow. 
         * When number of flows are small, we can quickly iterate over instead of storing separate list*/
        while(1) {
            /* loop over until next departure scheduled*/
            src = (src+1)%(NUM_SOURCES);
            while(flows[src].size() == 0) {
#ifdef DEBUG 
                cout<<"[Dequeue]\tEmpty "<<src<<" def"<<this->deficit[src]<<endl;
#endif
                src = (src+1)%(NUM_SOURCES);
            }
            /* increment deficit for each active  flow _before_ scheduling */
            this->deficit[src] += QUANTUM;
            /* check for deficit of the active flow */
            if(this->deficit[src] >= this->flows[src].front()->packetSize) {
                schedule_event(PKT_DEPART, this->flows[src].front()->packetId, src);
                this->deficit[src] -=  this->flows[src].front()->packetSize;
                break;
            }
#ifdef DEBUG
            cout<<"[Dequeue]\tSkipped: "<<src<<" def: "<<this->deficit[src]<<" pkt ";
            cout<<this->flows[src].front()->packetSize<<endl;
#endif
        }
    }
}