Back to index

glibc  2.9
Classes | Functions | Variables
posix-timer.h File Reference
#include <limits.h>
#include <signal.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  thread_node
struct  timer_node

Functions

static struct timer_nodetimer_id2ptr (timer_t timerid)
static int timer_ptr2id (struct timer_node *timer)
static int timer_valid (struct timer_node *timer)
void __timer_dealloc (struct timer_node *timer)
static void timer_addref (struct timer_node *timer)
static void timer_delref (struct timer_node *timer)
static int timespec_compare (const struct timespec *left, const struct timespec *right)
static void timespec_add (struct timespec *sum, const struct timespec *left, const struct timespec *right)
static void timespec_sub (struct timespec *diff, const struct timespec *left, const struct timespec *right)
static void list_unlink_ip (struct list_links *list)
void __timer_mutex_cancel_handler (void *arg)
void __timer_init_once (void)
struct timer_node__timer_alloc (void)
int __timer_thread_start (struct thread_node *thread)
struct thread_node__timer_thread_find_matching (const pthread_attr_t *desired_attr, clockid_t)
struct thread_node__timer_thread_alloc (const pthread_attr_t *desired_attr, clockid_t)
void __timer_thread_dealloc (struct thread_node *thread)
int __timer_thread_queue_timer (struct thread_node *thread, struct timer_node *insert)
void __timer_thread_wakeup (struct thread_node *thread)

Variables

pthread_mutex_t __timer_mutex
pthread_once_t __timer_init_once_control
int __timer_init_failed

Class Documentation

struct list_links

Definition at line 25 of file posix-timer.h.

Collaboration diagram for list_links:
Class Members
struct list_links * next
struct list_links * prev
struct thread_node

Definition at line 37 of file posix-timer.h.

Collaboration diagram for thread_node:
Class Members
pthread_attr_t attr
pthread_t captured
clockid_t clock_id
pthread_cond_t cond
struct timer_node * current_timer
unsigned int exists
pthread_t id

Function Documentation

struct timer_node* __timer_alloc ( void  ) [read]

Definition at line 539 of file timer_routines.c.

{
  struct list_links *node = list_first (&timer_free_list);

  if (node != list_null (&timer_free_list))
    {
      struct timer_node *timer = timer_links2ptr (node);
      list_unlink_ip (node);
      timer->inuse = TIMER_INUSE;
      timer->refcount = 1;
      return timer;
    }

  return NULL;
}

Here is the caller graph for this function:

void __timer_dealloc ( struct timer_node timer)

Definition at line 559 of file timer_routines.c.

{
  assert (timer->refcount == 0);
  timer->thread = NULL;     /* Break association between timer and thread.  */
  timer->inuse = TIMER_FREE;
  list_append (&timer_free_list, &timer->links);
}

Here is the caller graph for this function:

void __timer_init_once ( void  )

Definition at line 206 of file timer_routines.c.

Here is the caller graph for this function:

void __timer_mutex_cancel_handler ( void *  arg)

Definition at line 570 of file timer_routines.c.

Here is the call graph for this function:

Here is the caller graph for this function:

struct thread_node* __timer_thread_alloc ( const pthread_attr_t desired_attr,
clockid_t   
) [read]

Definition at line 226 of file timer_routines.c.

{
  struct list_links *node = list_first (&thread_free_list);

  if (node != list_null (&thread_free_list))
    {
      struct thread_node *thread = thread_links2ptr (node);
      list_unlink (node);
      thread_init (thread, desired_attr, clock_id);
      list_append (&thread_active_list, node);
      return thread;
    }

  return 0;
}

Here is the caller graph for this function:

void __timer_thread_dealloc ( struct thread_node thread)

Definition at line 246 of file timer_routines.c.

{
  thread_deinit (thread);
  list_unlink (&thread->links);
  list_append (&thread_free_list, &thread->links);
}

Here is the caller graph for this function:

struct thread_node* __timer_thread_find_matching ( const pthread_attr_t desired_attr,
clockid_t   
) [read]

Definition at line 516 of file timer_routines.c.

{
  struct list_links *iter = list_first (&thread_active_list);

  while (iter != list_null (&thread_active_list))
    {
      struct thread_node *candidate = thread_links2ptr (iter);

      if (thread_attr_compare (desired_attr, &candidate->attr)
         && desired_clock_id == candidate->clock_id)
       return candidate;

      iter = list_next (iter);
    }

  return NULL;
}

Here is the caller graph for this function:

int __timer_thread_queue_timer ( struct thread_node thread,
struct timer_node insert 
)

Definition at line 441 of file timer_routines.c.

{
  struct list_links *iter;
  int athead = 1;

  for (iter = list_first (&thread->timer_queue);
       iter != list_null (&thread->timer_queue);
        iter = list_next (iter))
    {
      struct timer_node *timer = timer_links2ptr (iter);

      if (timespec_compare (&insert->expirytime, &timer->expirytime) < 0)
         break;
      athead = 0;
    }

  list_insbefore (iter, &insert->links);
  return athead;
}

Here is the caller graph for this function:

int __timer_thread_start ( struct thread_node thread)

Definition at line 466 of file timer_routines.c.

{
  int retval = 1;

  assert (!thread->exists);
  thread->exists = 1;

  if (pthread_create (&thread->id, &thread->attr,
                    (void *(*) (void *)) thread_func, thread) != 0)
    {
      thread->exists = 0;
      retval = -1;
    }

  return retval;
}

Here is the caller graph for this function:

void __timer_thread_wakeup ( struct thread_node thread)

Definition at line 485 of file timer_routines.c.

{
  pthread_cond_broadcast (&thread->cond);
}

Here is the caller graph for this function:

static void list_unlink_ip ( struct list_links list) [inline, static]

Definition at line 178 of file posix-timer.h.

{
  struct list_links *lnext = list->next, *lprev = list->prev;

  lnext->prev = lprev;
  lprev->next = lnext;

  /* The suffix ip means idempotent; list_unlink_ip can be called
   * two or more times on the same node.
   */

  list->next = list;
  list->prev = list;
}

Here is the caller graph for this function:

static void timer_addref ( struct timer_node timer) [inline, static]

Definition at line 118 of file posix-timer.h.

{
  timer->refcount++;
}

Here is the caller graph for this function:

static void timer_delref ( struct timer_node timer) [inline, static]

Definition at line 124 of file posix-timer.h.

{
  if (--timer->refcount == 0)
    __timer_dealloc (timer);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static struct timer_node* timer_id2ptr ( timer_t  timerid) [static, read]

Definition at line 92 of file posix-timer.h.

{
  if (timerid >= 0 && timerid < TIMER_MAX)
    return &__timer_array[timerid];

  return NULL;
}
static int timer_ptr2id ( struct timer_node timer) [inline, static]

Definition at line 102 of file posix-timer.h.

{
  return timer - __timer_array;
}
static int timer_valid ( struct timer_node timer) [inline, static]

Definition at line 109 of file posix-timer.h.

{
  return timer && timer->inuse == TIMER_INUSE;
}

Here is the caller graph for this function:

static void timespec_add ( struct timespec sum,
const struct timespec left,
const struct timespec right 
) [inline, static]

Definition at line 148 of file posix-timer.h.

{
  sum->tv_sec = left->tv_sec + right->tv_sec;
  sum->tv_nsec = left->tv_nsec + right->tv_nsec;

  if (sum->tv_nsec >= 1000000000)
    {
      ++sum->tv_sec;
      sum->tv_nsec -= 1000000000;
    }
}

Here is the caller graph for this function:

static int timespec_compare ( const struct timespec left,
const struct timespec right 
) [inline, static]

Definition at line 132 of file posix-timer.h.

{
  if (left->tv_sec < right->tv_sec)
    return -1;
  if (left->tv_sec > right->tv_sec)
    return 1;

  if (left->tv_nsec < right->tv_nsec)
    return -1;
  if (left->tv_nsec > right->tv_nsec)
    return 1;

  return 0;
}

Here is the caller graph for this function:

static void timespec_sub ( struct timespec diff,
const struct timespec left,
const struct timespec right 
) [inline, static]

Definition at line 162 of file posix-timer.h.

{
  diff->tv_sec = left->tv_sec - right->tv_sec;
  diff->tv_nsec = left->tv_nsec - right->tv_nsec;

  if (diff->tv_nsec < 0)
    {
      --diff->tv_sec;
      diff->tv_nsec += 1000000000;
    }
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 51 of file timer_routines.c.

Definition at line 48 of file timer_routines.c.

Definition at line 45 of file timer_routines.c.