<commit_before>/*
 * OLSR ad-hoc routing table management protocol
 * Copyright (C) 2004 <NAME> (<EMAIL>)
 *
 * This file is part of the olsr.org OLSR daemon.
 *
 * olsr.org is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * olsr.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with olsr.org; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * 
 * $Id: scheduler.c,v 1.18 2004/11/15 15:50:08 tlopatic Exp $
 *
 */


#include "defs.h"
#include "scheduler.h"
#include "tc_set.h"
#include "link_set.h"
#include "duplicate_set.h"
#include "mpr_selector_set.h"
#include "mid_set.h"
#include "mpr.h"
#include "olsr.h"
#include "build_msg.h"


static float pollrate;



/**
 *Main scheduler event loop. Polls at every
 *sched_poll_interval and calls all functions
 *that are timed out or that are triggered.
 *Also calls the olsr_process_changes()
 *function at every poll.
 *
 *
 *@return nada
 */

void
scheduler()
{
  struct timespec remainder_spec;
  struct timespec sleeptime_spec;

  /*
   *Used to calculate sleep time
   */
  struct timeval start_of_loop;
  struct timeval end_of_loop;
  struct timeval time_used;
  struct timeval interval;
  struct timeval sleeptime_val;

  olsr_u32_t interval_usec;

  struct event_entry *entry;
  struct timeout_entry *time_out_entry;

  struct interface *ifn;
 
  pollrate = olsr_cnf->pollrate;

  interval_usec = (olsr_u32_t)(pollrate * 1000000);

  interval.tv_sec = interval_usec / 1000000;
  interval.tv_usec = interval_usec % 1000000;

  olsr_printf(1, "Scheduler started - polling every %0.2f seconds\n", pollrate);

  olsr_printf(3, "Max jitter is %f\n\n", max_jitter);



  /* Main scheduler event loop */

  for(;;)
    {

      gettimeofday(&start_of_loop, NULL);

      /* Update the global timestamp */
      gettimeofday(&now, NULL);
      nowtm = gmtime((time_t *)&now.tv_sec);

      while (nowtm == NULL)
	{
	  nowtm = gmtime((time_t *)&now.tv_sec);
	}


      /* Run timout functions (before packet generation) */

      time_out_entry = timeout_functions;
      
      while(time_out_entry)
	{
	  time_out_entry->function();
	  time_out_entry = time_out_entry->next;
	}

      /* Update */
      
      olsr_process_changes();


      /* Check for changes in topology */

      if(changes)
	{
          // if the MPR selector set was update, we have to print
          // the updated neighbour table, as it now contains an
          // "MPRS" column

          olsr_print_neighbor_table();

	  olsr_printf(3, "ANSN UPDATED %d\n\n", ansn);
	  ansn++;<commit_msg>Fixed comment.<commit_after>/*
 * OLSR ad-hoc routing table management protocol
 * Copyright (C) 2004 <NAME> (<EMAIL>)
 *
 * This file is part of the olsr.org OLSR daemon.
 *
 * olsr.org is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * olsr.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with olsr.org; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * 
 * $Id: scheduler.c,v 1.19 2004/11/15 15:56:07 tlopatic Exp $
 *
 */


#include "defs.h"
#include "scheduler.h"
#include "tc_set.h"
#include "link_set.h"
#include "duplicate_set.h"
#include "mpr_selector_set.h"
#include "mid_set.h"
#include "mpr.h"
#include "olsr.h"
#include "build_msg.h"


static float pollrate;



/**
 *Main scheduler event loop. Polls at every
 *sched_poll_interval and calls all functions
 *that are timed out or that are triggered.
 *Also calls the olsr_process_changes()
 *function at every poll.
 *
 *
 *@return nada
 */

void
scheduler()
{
  struct timespec remainder_spec;
  struct timespec sleeptime_spec;

  /*
   *Used to calculate sleep time
   */
  struct timeval start_of_loop;
  struct timeval end_of_loop;
  struct timeval time_used;
  struct timeval interval;
  struct timeval sleeptime_val;

  olsr_u32_t interval_usec;

  struct event_entry *entry;
  struct timeout_entry *time_out_entry;

  struct interface *ifn;
 
  pollrate = olsr_cnf->pollrate;

  interval_usec = (olsr_u32_t)(pollrate * 1000000);

  interval.tv_sec = interval_usec / 1000000;
  interval.tv_usec = interval_usec % 1000000;

  olsr_printf(1, "Scheduler started - polling every %0.2f seconds\n", pollrate);

  olsr_printf(3, "Max jitter is %f\n\n", max_jitter);



  /* Main scheduler event loop */

  for(;;)
    {

      gettimeofday(&start_of_loop, NULL);

      /* Update the global timestamp */
      gettimeofday(&now, NULL);
      nowtm = gmtime((time_t *)&now.tv_sec);

      while (nowtm == NULL)
	{
	  nowtm = gmtime((time_t *)&now.tv_sec);
	}


      /* Run timout functions (before packet generation) */

      time_out_entry = timeout_functions;
      
      while(time_out_entry)
	{
	  time_out_entry->function();
	  time_out_entry = time_out_entry->next;
	}

      /* Update */
      
      olsr_process_changes();


      /* Check for changes in topology */

      if(changes)
	{
          // if the MPR selector might have been updated, we have to print
          // the updated neighbour table, as it now contains an "MPRS" column

          olsr_print_neighbor_table();

	  olsr_printf(3, "ANSN UPDATED %d\n\n", ansn);
	  ansn++;
{'fraction_non_alphanumeric': 0.09942481511914544, 'fraction_numerical': 0.02169268693508628, 'mean_word_length': 3.2470341939986045, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4844362', 'n_tokens_mistral': 2186, 'n_tokens_neox': 1979, 'n_words': 653}