Back to index

glibc  2.9
Classes | Defines | 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

Defines

#define TIMER_MAX   256
#define timer_id2ptr(timerid)   ((struct timer_node *) timerid)
#define timer_ptr2id(timerid)   ((void *) timerid)

Functions

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 __attribute ((always_inline)) timespec_compare(const struct timespec *left
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

Define Documentation

#define timer_id2ptr (   timerid)    ((struct timer_node *) timerid)

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

#define TIMER_MAX   256

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

#define timer_ptr2id (   timerid)    ((void *) timerid)

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


Function Documentation

static int __attribute ( (always_inline)  ) const [inline, static]
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 call 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 call graph for this function:

void __timer_init_once ( void  ) [read]

Definition at line 206 of file timer_routines.c.

Here is the call 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 call 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 call 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 call 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 call 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 call 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 call graph for this function:

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

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

{
  timer->refcount++;
}
static void timer_delref ( struct timer_node timer) [inline, static]

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

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

Here is the call graph for this function:

static int timer_valid ( struct timer_node timer) [inline, static]

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

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

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.