utcb_watch.c File Reference

Timeslice watching using the UTCB Ring-buffer of scheduling events. More...

Go to the source code of this file.

Data Structures

struct  utcb_list_t
 List-element to manage utcbs/threads. More...
struct  watch_arg_t
 argument type for IPC-communication with watch thread More...

Typedefs

typedef enum watch_cmd_val_t watch_cmd_t
 Cmd-type for IPC-communication with watch thread.

Enumerations

enum  watch_cmd_val_t { WATCH_CMD_INV, WATCH_CMD_ADD, WATCH_CMD_DEL }
 Cmd-type for IPC-communication with watch thread. More...

Functions

static void watch_thread (void *arg)
 The main watcher thread.
int l4cpu_reserve_utcb_watch_add (l4_threadid_t thread, l4cpu_reserve_utcb_t *utcb, const char *name, unsigned maxtime, int ts_count)
 Add a thread to the watched threads.
int l4cpu_reserve_utcb_watch_del (const l4cpu_reserve_utcb_t *utcb)
 Stop watching of a thread.
int l4cpu_reserve_utcb_watch_init (int poll_interval)
 Initialize watching threads using the utcb rings.
static int watch_add_utcb_do (watch_arg_t *arg)
 Actually add a new thread to the list of watched threads.
static int watch_del_utcb_do (const l4cpu_reserve_utcb_t *utcb)
 Actually remove a thread from the list of watched threads.
static void watch_insert_sample (utcb_list_t *l, int id, long time)
 Helper function to add a sample to a timeslice of a thread.
static int watch_add_res_entry (utcb_list_t *l, int id, unsigned long long release, long time)
 Add a history element: end of reservation/next reservation.
static void watch_add_period_entry (utcb_list_t *l, int id, unsigned long long release, long time)
 Add a history element: end of period/next period.
static void watch_add_lost (utcb_list_t *l, int count)
 Add a history element: end of period/next period.
static void print_sched_event (int id, l4cpu_reserve_utcb_elem_t *stat) __attribute__((unused))
 Dump a scheduling element to the console.
static void watch_eval_utcbs (void)
 Poll all watched threads for new events.

Variables

static utcb_list_tutcb_list
 the utcbs/threads are kept in this list
static l4_threadid_t watch_thread_id
 thread-id of watcher thread


Detailed Description

Timeslice watching using the UTCB Ring-buffer of scheduling events.

Date:
01/12/2005
Author:
Jork Loeser <jork.loeser@inf.tu-dresden.de>

Definition in file utcb_watch.c.


Typedef Documentation

Cmd-type for IPC-communication with watch thread.


Enumeration Type Documentation

Cmd-type for IPC-communication with watch thread.

Enumerator:
WATCH_CMD_INV 
WATCH_CMD_ADD 
WATCH_CMD_DEL 

Definition at line 43 of file utcb_watch.c.


Function Documentation

int l4cpu_reserve_utcb_watch_add ( l4_threadid_t  thread,
l4cpu_reserve_utcb_t utcb,
const char *  name,
unsigned  maxtime,
int  ts_count 
)

Add a thread to the watched threads.

Parameters:
thread thread to be watched
utcb pointer to the utcb of that thread
name name of the thread/watch entity
ts_count maximum number of timeslices to watch (incl. the be-timeslice)
Return values:
0 OK, error else

Definition at line 70 of file utcb_watch.c.

References L4CPU_RESERVE_UTCB_NAME_LEN, watch_arg_t::maxtime, watch_arg_t::name, watch_arg_t::thread, watch_arg_t::ts_count, watch_arg_t::utcb, WATCH_CMD_ADD, and watch_thread_id.

int l4cpu_reserve_utcb_watch_del ( const l4cpu_reserve_utcb_t utcb  ) 

Stop watching of a thread.

Parameters:
thread thread that is not to be watched any longer
Return values:
0 OK, error else

Definition at line 95 of file utcb_watch.c.

References WATCH_CMD_DEL, and watch_thread_id.

int l4cpu_reserve_utcb_watch_init ( int  polltime  ) 

Initialize watching threads using the utcb rings.

Parameters:
poll_interval poll interval, in microseconds
Return values:
0 OK, error else

Definition at line 108 of file utcb_watch.c.

References watch_thread(), and watch_thread_id.

static void print_sched_event ( int  id,
l4cpu_reserve_utcb_elem_t stat 
) [static]

static void watch_add_lost ( utcb_list_t l,
int  count 
) [static]

Add a history element: end of period/next period.

This function sets the history element of the given id to the given time. For all rt-timeslices that got no reservation in this period, a history-element with time 0 will be added.

Definition at line 262 of file utcb_watch.c.

References utcb_list_t::hists, and utcb_list_t::ts_count.

Referenced by watch_eval_utcbs().

static void watch_add_period_entry ( utcb_list_t l,
int  id,
unsigned long long  release,
long  time 
) [static]

Add a history element: end of period/next period.

This function sets the history element of the given id to the given time. For all rt-timeslices that got no reservation in this period, a history-element with time 0 will be added.

Definition at line 243 of file utcb_watch.c.

References utcb_list_t::ts_count, utcb_list_t::ts_num, watch_add_res_entry(), and watch_insert_sample().

Referenced by watch_eval_utcbs().

static int watch_add_res_entry ( utcb_list_t l,
int  id,
unsigned long long  release,
long  time 
) [static]

Add a history element: end of reservation/next reservation.

This function sets the history element of the given id to the given time. For all rt-timeslices below the given one, a history-element with time 0 will be added.

Definition at line 215 of file utcb_watch.c.

References utcb_list_t::period, utcb_list_t::release, utcb_list_t::ts_count, utcb_list_t::ts_num, and watch_insert_sample().

Referenced by watch_add_period_entry(), and watch_eval_utcbs().

static int watch_add_utcb_do ( watch_arg_t arg  )  [static]

static int watch_del_utcb_do ( const l4cpu_reserve_utcb_t utcb  )  [static]

Actually remove a thread from the list of watched threads.

Definition at line 171 of file utcb_watch.c.

References utcb_list_t::hists, utcb_list_t::next, utcb_list_t::ts_count, and utcb_list_t::utcb.

Referenced by watch_thread().

static void watch_eval_utcbs ( void   )  [static]

static void watch_insert_sample ( utcb_list_t l,
int  id,
long  time 
) [static]

Helper function to add a sample to a timeslice of a thread.

Parameters:
l utcb-list describing the thread
id timeslice id
time consumed time of the timeslice in the current period

Definition at line 201 of file utcb_watch.c.

References utcb_list_t::hists.

Referenced by watch_add_period_entry(), and watch_add_res_entry().

static void watch_thread ( void *  arg  )  [static]

The main watcher thread.

This thread waits for requests from other threads to add/remove threads and periodically polls the watched threads for events.

Definition at line 325 of file utcb_watch.c.

References watch_add_utcb_do(), WATCH_CMD_ADD, WATCH_CMD_DEL, watch_del_utcb_do(), watch_eval_utcbs(), and watch_thread_id.

Referenced by l4cpu_reserve_utcb_watch_init().


Variable Documentation

the utcbs/threads are kept in this list

Definition at line 59 of file utcb_watch.c.

l4_threadid_t watch_thread_id [static]

thread-id of watcher thread

Definition at line 62 of file utcb_watch.c.

Referenced by l4cpu_reserve_utcb_watch_add(), l4cpu_reserve_utcb_watch_del(), l4cpu_reserve_utcb_watch_init(), and watch_thread().


CPU reservation server Reference Manual, written by Jork Loeser  © 2004