Time management


Files

file  clock.h
file  delay.h
file  timeout.h
file  clock.c
 High-level clock interrupt handler.
file  delay.c
 Active delay function.
file  timeout.c
 Timeout management functions.

Data Structures

struct  timeout
struct  ptime

Defines

#define HZ   100
#define us2ticks(us)   ((__u64)(((__u32) (us)/(1000000/HZ))))

Typedefs

typedef void(* timeout_handler_t )(void *arg)

Functions

void clock (void)
void clock_counter_init (void)
void delay (__u32 microseconds)
void timeout_init (void)
void timeout_initialize (timeout_t *t)
void timeout_reinitialize (timeout_t *t)
void timeout_register (timeout_t *t, __u64 usec, timeout_handler_t f, void *arg)
bool timeout_unregister (timeout_t *t)
static void clock_update_counters (void)

Variables

ptimepublic_time
static __native secfrag = 0

Define Documentation

#define HZ   100
 

Definition at line 38 of file clock.h.

Referenced by clock_update_counters().

#define us2ticks us   )     ((__u64)(((__u32) (us)/(1000000/HZ))))
 

Definition at line 43 of file timeout.h.

Referenced by timeout_register().


Typedef Documentation

typedef void(* timeout_handler_t)(void *arg)
 

Definition at line 45 of file timeout.h.


Function Documentation

void clock void   ) 
 

Clock routine

Clock routine executed from clock interrupt handler (assuming interrupts_disable()'d). Runs expired timeouts and preemptive scheduling.

Definition at line 125 of file clock.c.

References timeout::arg, clock_update_counters(), CPU, f, timeout::handler, list_get_instance, list_remove(), spinlock_lock, spinlock_unlock(), timeout::ticks, and timeout_reinitialize().

Referenced by exception_decrementer().

Here is the call graph for this function:

void clock_counter_init void   ) 
 

Initialize realtime clock counter

The applications (and sometimes kernel) need to access accurate information about realtime data. We allocate 1 page with these data and update it periodically.

Definition at line 78 of file clock.c.

References frame_alloc, FRAME_ATOMIC, NULL, panic, PFN2ADDR(), public_time, ptime::seconds1, ptime::seconds2, sysinfo_set_item_val(), and ptime::useconds.

Referenced by main_bsp_separated_stack().

Here is the call graph for this function:

static void clock_update_counters void   )  [static]
 

Update public counters

Update it only on first processor TODO: Do we really need so many write barriers?

Definition at line 102 of file clock.c.

References CPU, HZ, public_time, secfrag, ptime::seconds1, ptime::seconds2, ptime::useconds, and write_barrier.

Referenced by clock().

void delay __u32  usec  ) 
 

Active delay

Delay the execution for the given number of microseconds (or slightly more). The delay is implemented as CPU calibrated active loop.

Parameters:
usec Number of microseconds to sleep.

Definition at line 52 of file delay.c.

References asm_delay_loop(), CPU, interrupts_disable(), and interrupts_restore().

Referenced by scheduler_separated_stack().

Here is the call graph for this function:

void timeout_init void   ) 
 

Initialize timeouts

Initialize kernel timeouts.

Definition at line 55 of file timeout.c.

References CPU, list_initialize(), and spinlock_initialize().

Referenced by main_ap_separated_stack(), and main_bsp_separated_stack().

Here is the call graph for this function:

void timeout_initialize timeout_t t  ) 
 

Initialize timeout

Initialize all members including the lock.

Parameters:
t Timeout to be initialized.

Definition at line 86 of file timeout.c.

References spinlock_initialize(), and timeout_reinitialize().

Referenced by thread_create().

Here is the call graph for this function:

void timeout_register timeout_t t,
__u64  time,
timeout_handler_t  f,
void *  arg
 

Register timeout

Insert timeout handler f (with argument arg) to timeout list and make it execute in time microseconds (or slightly more).

Parameters:
t Timeout structure.
time Number of usec in the future to execute the handler.
f Timeout handler function.
arg Timeout handler argument.

Definition at line 106 of file timeout.c.

References timeout::arg, timeout::cpu, CPU, timeout::handler, interrupts_disable(), interrupts_restore(), timeout::link, list_get_instance, list_prepend(), link::next, NULL, panic, link::prev, spinlock_lock, spinlock_unlock(), timeout::ticks, and us2ticks.

Referenced by waitq_sleep_timeout_unsafe().

Here is the call graph for this function:

void timeout_reinitialize timeout_t t  ) 
 

Reinitialize timeout

Initialize all members except the lock.

Parameters:
t Timeout to be initialized.

Definition at line 69 of file timeout.c.

References timeout::arg, timeout::cpu, timeout::handler, timeout::link, link_initialize(), NULL, and timeout::ticks.

Referenced by clock(), timeout_initialize(), and timeout_unregister().

Here is the call graph for this function:

bool timeout_unregister timeout_t t  ) 
 

Unregister timeout

Remove timeout from timeout list.

Parameters:
t Timeout to unregister.
Returns:
true on success, false on failure.

Definition at line 174 of file timeout.c.

References timeout::cpu, interrupts_disable(), interrupts_restore(), timeout::link, list_get_instance, list_remove(), link::next, spinlock_lock, spinlock_trylock(), spinlock_unlock(), timeout::ticks, cpu::timeout_active_head, and timeout_reinitialize().

Referenced by _waitq_wakeup_unsafe(), and waitq_interrupt_sleep().

Here is the call graph for this function:


Variable Documentation

struct ptime* public_time
 

Definition at line 64 of file clock.c.

Referenced by clock_counter_init(), and clock_update_counters().

__native secfrag = 0 [static]
 

Definition at line 68 of file clock.c.

Referenced by clock_update_counters().


Generated on Sun Jun 18 17:31:40 2006 for HelenOS Kernel (ppc64) by  doxygen 1.4.6