version 1.1.1.3, 2013/07/21 23:54:39
|
version 1.1.1.4, 2016/11/02 10:09:10
|
Line 1
|
Line 1
|
/* Thread management routine header. |
/* Thread management routine header. |
* Copyright (C) 1998 Kunihiro Ishiguro |
* Copyright (C) 1998 Kunihiro Ishiguro |
* Portions Copyright (c) 2008 Everton da Silva Marques <everton.marques@gmail.com> |
|
* |
* |
* This file is part of GNU Zebra. |
* This file is part of GNU Zebra. |
* |
* |
Line 44 struct thread_list
|
Line 43 struct thread_list
|
int count; |
int count; |
}; |
}; |
|
|
|
struct pqueue; |
|
|
/* Master of the theads. */ |
/* Master of the theads. */ |
struct thread_master |
struct thread_master |
{ |
{ |
struct thread_list read; |
struct thread_list read; |
struct thread_list write; |
struct thread_list write; |
struct thread_list timer; | struct pqueue *timer; |
struct thread_list event; |
struct thread_list event; |
struct thread_list ready; |
struct thread_list ready; |
struct thread_list unuse; |
struct thread_list unuse; |
struct thread_list background; | struct pqueue *background; |
fd_set readfd; |
fd_set readfd; |
fd_set writefd; |
fd_set writefd; |
fd_set exceptfd; |
fd_set exceptfd; |
Line 62 struct thread_master
|
Line 63 struct thread_master
|
|
|
typedef unsigned char thread_type; |
typedef unsigned char thread_type; |
|
|
/* ISO C99 maximum function name length is 63 */ |
|
#define FUNCNAME_LEN 64 |
|
|
|
/* Thread itself. */ |
/* Thread itself. */ |
struct thread |
struct thread |
{ |
{ |
Line 80 struct thread
|
Line 78 struct thread
|
int fd; /* file descriptor in case of read/write. */ |
int fd; /* file descriptor in case of read/write. */ |
struct timeval sands; /* rest of time sands value. */ |
struct timeval sands; /* rest of time sands value. */ |
} u; |
} u; |
|
int index; /* used for timers to store position in queue */ |
struct timeval real; |
struct timeval real; |
struct cpu_thread_history *hist; /* cache pointer to cpu_history */ |
struct cpu_thread_history *hist; /* cache pointer to cpu_history */ |
char funcname[FUNCNAME_LEN]; | const char *funcname; |
| const char *schedfrom; |
| int schedfrom_line; |
}; |
}; |
|
|
struct cpu_thread_history |
struct cpu_thread_history |
Line 97 struct cpu_thread_history
|
Line 98 struct cpu_thread_history
|
struct time_stats cpu; |
struct time_stats cpu; |
#endif |
#endif |
thread_type types; |
thread_type types; |
char funcname[FUNCNAME_LEN]; | const char *funcname; |
}; |
}; |
|
|
/* Clocks supported by Quagga */ |
/* Clocks supported by Quagga */ |
Line 162 enum quagga_clkid {
|
Line 163 enum quagga_clkid {
|
#define THREAD_WRITE_OFF(thread) THREAD_OFF(thread) |
#define THREAD_WRITE_OFF(thread) THREAD_OFF(thread) |
#define THREAD_TIMER_OFF(thread) THREAD_OFF(thread) |
#define THREAD_TIMER_OFF(thread) THREAD_OFF(thread) |
|
|
#define thread_add_read(m,f,a,v) funcname_thread_add_read(m,f,a,v,#f) | #define debugargdef const char *funcname, const char *schedfrom, int fromln |
#define thread_add_write(m,f,a,v) funcname_thread_add_write(m,f,a,v,#f) | |
#define thread_add_timer(m,f,a,v) funcname_thread_add_timer(m,f,a,v,#f) | |
#define thread_add_timer_msec(m,f,a,v) funcname_thread_add_timer_msec(m,f,a,v,#f) | |
#define thread_add_event(m,f,a,v) funcname_thread_add_event(m,f,a,v,#f) | |
#define thread_execute(m,f,a,v) funcname_thread_execute(m,f,a,v,#f) | |
|
|
|
#define thread_add_read(m,f,a,v) funcname_thread_add_read(m,f,a,v,#f,__FILE__,__LINE__) |
|
#define thread_add_write(m,f,a,v) funcname_thread_add_write(m,f,a,v,#f,__FILE__,__LINE__) |
|
#define thread_add_timer(m,f,a,v) funcname_thread_add_timer(m,f,a,v,#f,__FILE__,__LINE__) |
|
#define thread_add_timer_msec(m,f,a,v) funcname_thread_add_timer_msec(m,f,a,v,#f,__FILE__,__LINE__) |
|
#define thread_add_event(m,f,a,v) funcname_thread_add_event(m,f,a,v,#f,__FILE__,__LINE__) |
|
#define thread_execute(m,f,a,v) funcname_thread_execute(m,f,a,v,#f,__FILE__,__LINE__) |
|
|
/* The 4th arg to thread_add_background is the # of milliseconds to delay. */ |
/* The 4th arg to thread_add_background is the # of milliseconds to delay. */ |
#define thread_add_background(m,f,a,v) funcname_thread_add_background(m,f,a,v,#f) | #define thread_add_background(m,f,a,v) funcname_thread_add_background(m,f,a,v,#f,__FILE__,__LINE__) |
|
|
/* Prototypes. */ |
/* Prototypes. */ |
extern struct thread_master *thread_master_create (void); |
extern struct thread_master *thread_master_create (void); |
Line 178 extern void thread_master_free (struct thread_master *
|
Line 181 extern void thread_master_free (struct thread_master *
|
|
|
extern struct thread *funcname_thread_add_read (struct thread_master *, |
extern struct thread *funcname_thread_add_read (struct thread_master *, |
int (*)(struct thread *), |
int (*)(struct thread *), |
void *, int, const char*); | void *, int, debugargdef); |
extern struct thread *funcname_thread_add_write (struct thread_master *, |
extern struct thread *funcname_thread_add_write (struct thread_master *, |
int (*)(struct thread *), |
int (*)(struct thread *), |
void *, int, const char*); | void *, int, debugargdef); |
extern struct thread *funcname_thread_add_timer (struct thread_master *, |
extern struct thread *funcname_thread_add_timer (struct thread_master *, |
int (*)(struct thread *), |
int (*)(struct thread *), |
void *, long, const char*); | void *, long, debugargdef); |
extern struct thread *funcname_thread_add_timer_msec (struct thread_master *, |
extern struct thread *funcname_thread_add_timer_msec (struct thread_master *, |
int (*)(struct thread *), |
int (*)(struct thread *), |
void *, long, const char*); | void *, long, debugargdef); |
extern struct thread *funcname_thread_add_event (struct thread_master *, |
extern struct thread *funcname_thread_add_event (struct thread_master *, |
int (*)(struct thread *), |
int (*)(struct thread *), |
void *, int, const char*); | void *, int, debugargdef); |
extern struct thread *funcname_thread_add_background (struct thread_master *, |
extern struct thread *funcname_thread_add_background (struct thread_master *, |
int (*func)(struct thread *), |
int (*func)(struct thread *), |
void *arg, |
void *arg, |
long milliseconds_to_delay, |
long milliseconds_to_delay, |
const char *funcname); | debugargdef); |
extern struct thread *funcname_thread_execute (struct thread_master *, |
extern struct thread *funcname_thread_execute (struct thread_master *, |
int (*)(struct thread *), |
int (*)(struct thread *), |
void *, int, const char *); | void *, int, debugargdef); |
| #undef debugargdef |
| |
extern void thread_cancel (struct thread *); |
extern void thread_cancel (struct thread *); |
extern unsigned int thread_cancel_event (struct thread_master *, void *); |
extern unsigned int thread_cancel_event (struct thread_master *, void *); |
extern struct thread *thread_fetch (struct thread_master *, struct thread *); |
extern struct thread *thread_fetch (struct thread_master *, struct thread *); |
extern void thread_call (struct thread *); |
extern void thread_call (struct thread *); |
extern unsigned long thread_timer_remain_second (struct thread *); |
extern unsigned long thread_timer_remain_second (struct thread *); |
|
extern struct timeval thread_timer_remain(struct thread*); |
extern int thread_should_yield (struct thread *); |
extern int thread_should_yield (struct thread *); |
|
extern unsigned long timeval_elapsed (struct timeval a, struct timeval b); |
|
|
/* Internal libzebra exports */ |
/* Internal libzebra exports */ |
extern void thread_getrusage (RUSAGE_T *); |
extern void thread_getrusage (RUSAGE_T *); |
Line 228 extern unsigned long thread_consumed_time(RUSAGE_T *af
|
Line 235 extern unsigned long thread_consumed_time(RUSAGE_T *af
|
extern struct timeval recent_time; |
extern struct timeval recent_time; |
/* Similar to recent_time, but a monotonically increasing time value */ |
/* Similar to recent_time, but a monotonically increasing time value */ |
extern struct timeval recent_relative_time (void); |
extern struct timeval recent_relative_time (void); |
|
|
|
/* only for use in logging functions! */ |
|
extern struct thread *thread_current; |
|
|
#endif /* _ZEBRA_THREAD_H */ |
#endif /* _ZEBRA_THREAD_H */ |