[Olsr-dev] OLSR Basic Multicast Forwarding (BMF) plugin v1.6.1 available

Henning Rogge (spam-protected)
Tue Jul 29 11:34:17 CEST 2008


Am Dienstag 29 Juli 2008 10:55:10 schrieb Erik Tromp:
> Hi all,
>
> A new version of the Basic Multicast Forwarding (BMF) plugin is available.
>
> Here is the change log of version 1.6.1 with respect to the previous
> version 1.6:
> * Introduced a mutex for safe access to the OLSR data by the BMF thread.

Maybe we should include the locking semaphore into the main branch. 
Overwriting files of the main branch from a plugin is a bad idea because it's 
very dependent on the version of the main branch.

In addition to this I would do the modified olsr_scheduler_sleep a little bit 
different to prevent starvation of the utility threads.

Maybe we could think about an infrastructure in the scheduler that would allow 
plugins like the bmf to use the olsr mainloop instead of a thread of it's 
own ?




static void
olsr_scheduler_sleep(clock_t scheduler_runtime)
{
  struct timespec remainder_spec, sleeptime_spec;
  struct timeval sleeptime_val, time_used, next_interval;
  olsr_u32_t next_interval_usec;
  clock_t milliseconds_used;

  /* Calculate next planned scheduler invocation */
  next_interval_usec = olsr_cnf->pollrate * USEC_PER_SEC;
  next_interval.tv_sec = next_interval_usec / USEC_PER_SEC;
  next_interval.tv_usec = next_interval_usec % USEC_PER_SEC;

  /* Determine used runtime */
  milliseconds_used = scheduler_runtime * olsr_cnf->system_tick_divider;
  time_used.tv_sec = milliseconds_used / MSEC_PER_SEC;
  time_used.tv_usec = (milliseconds_used % MSEC_PER_SEC) * USEC_PER_MSEC;

  /* While sleeping, other threads may use the OLSR data */
  pthread_mutex_unlock(&olsr_mutex);

  if (timercmp(&time_used, &next_interval, <)) {
    timersub(&next_interval, &time_used, &sleeptime_val);

    sleeptime_spec.tv_sec = sleeptime_val.tv_sec;
    sleeptime_spec.tv_nsec = sleeptime_val.tv_usec * NSEC_PER_USEC;

    while (nanosleep(&sleeptime_spec, &remainder_spec) < 0)
      sleeptime_spec = remainder_spec;
  }
  /* Grab the mutex as soon as we wake up again */
  pthread_mutex_lock(&olsr_mutex);
}



*************************************************
Diplom Informatiker Henning Rogge
Forschungsgesellschaft für
Angewandte Naturwissenschaften e. V. (FGAN) 
Neuenahrer Str. 20, 53343 Wachtberg, Germany
Tel.: 0049 (0)228 9435-961
Fax: 0049 (0)228 9435-685
E-Mail: (spam-protected)
Web: www.fgan.de
************************************************
Sitz der Gesellschaft: Bonn
Registergericht: Amtsgericht Bonn VR 2530
Vorstand: Dr. rer. nat. Ralf Dornhaus (Vors.), Prof. Dr. Joachim Ender 
(Stellv.)




More information about the Olsr-dev mailing list