From c124ecc9f502b11f331153ffaba243b7b1031a92 Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Wed, 6 Apr 2011 16:48:24 -0400 Subject: Consolidated data into server_domain_t. --- include/litmus/servers.h | 179 ++++++++++++++++++++++++++++------------------- 1 file changed, 106 insertions(+), 73 deletions(-) (limited to 'include') diff --git a/include/litmus/servers.h b/include/litmus/servers.h index 97fd0ce76207..d3e45857653b 100644 --- a/include/litmus/servers.h +++ b/include/litmus/servers.h @@ -3,125 +3,161 @@ struct server; struct periodic_server; -struct proc_read_args; struct proc_dir_entry; struct server_domain; struct server_release_heap; +struct completion_timer; +struct server_proc; #define SERVER_RELEASE_QUEUE_SLOTS 127 #define SERVER_FMT "{server/%d:%d}" #define SERVER_ARGS(s) (s)->id, (s)->job_no +#define server_task(s) (((s)->cpu != NO_CPU)?s->domain->linked_tasks[(s)->cpu]:NULL) +#define is_server_linked(s) ((s)->cpu != NO_CPU) + /* - * Called when a server is released. - */ -typedef void (*post_release_t)(struct periodic_server *server); -/* - * Called when a server exhausts its budget. - */ -typedef void (*server_completed_t)(struct server *server, - struct task_struct *was_running); -/* - * Used to read server entries. - */ -typedef int (*admit_server_t)(unsigned long long wcet, - unsigned long long period, int cpu); -/* - * Must call server_proc_read on each server to print. - */ -typedef void (*list_servers_t)(struct proc_read_args *args); -/* - * Called after each proc write before new values are read. - */ -typedef void (*stop_servers_t)(void); -/* - * Called when a group of servers release + * A single schedulable server. */ -typedef void (*servers_released_t)(struct list_head *servers); - typedef struct server { /* Specified by the user */ int id; lt_t wcet; lt_t period; + /* Optional */ + int type; + void* data; + /* Managed internally */ lt_t deadline; lt_t release; lt_t budget; /* The remaining budget for current period */ - lt_t start_time; /* The time the server started executing or 0 */ - int running; /* True if server is currently executing */ int job_no; /* Current job of server */ + int cpu; /* CPU the server is running on or NO_CPU */ - int type; /* Optional */ - - /* Used for grouped releases */ - struct server_release_heap *release_heap; - struct list_head release_list; + struct server_domain *domain; - /* Useful in general */ + /* For membership in collections */ struct bheap_node *hn; struct list_head list; - void* data; - - struct task_struct* scheduled; + /* Used for grouped releases */ + struct server_release_heap *release_heap; + struct list_head release_list; } server_t; /* - * Because pointer arithmetic wasn't working. TODO: pointer arithmetic + * Called when a server exhausts its budget. */ -typedef struct completion_timer { - int armed; - int cpu; - struct hrtimer timer; - struct hrtimer_start_on_info info; - struct server_domain *domain; -} completion_timer_t; +typedef void (*server_completed_t)(struct server *server, + struct task_struct *was_running); +/* + * Called when a group of servers release + */ +typedef void (*servers_released_t)(struct list_head *servers); +/* + * Used to read server entries. + */ +typedef int (*admit_server_t)(unsigned long long wcet, + unsigned long long period, int cpu); +/* + * Lists all servers for a proc entry by calling list_server on each. + */ +typedef void (*list_servers_t)(struct server_proc *proc); +/* + * Stop all servers. Used to destroy servers on a proc entry rewrite. + */ +typedef void (*stop_servers_t)(void); /* * Useful tools for scheduling servers. */ typedef struct server_domain { + /* Collection of grouped releases */ raw_spinlock_t release_lock; struct list_head release_queue[SERVER_RELEASE_QUEUE_SLOTS]; - int release_master; + /* List of tasks to be added to the grouped releases */ + raw_spinlock_t tobe_lock; + struct list_head tobe_released; - completion_timer_t* completion_timers; - server_t** running; + /* CPU on which to release servers */ + int release_master; - raw_spinlock_t* timer_lock; + /* Per CPU information for running servers */ + struct completion_timer* completion_timers; + server_t** linked_servers; + struct task_struct** linked_tasks; + lt_t* start_times; + /* Used to lock firing of the completion timer. + * This is needed here and not for the release timer because + * the completion timer actually modifies the state of the + * server itself. + */ + raw_spinlock_t* completion_lock; + + /* Event callbacks */ server_completed_t server_completed; servers_released_t servers_released; - struct kmem_cache *server_release_cache; - - raw_spinlock_t tobe_lock; - struct list_head tobe_released; + /* Proc entries for controlling groups of servers */ + struct list_head server_procs; } server_domain_t; /* * A group of servers releasing simultaneously. */ typedef struct server_release_heap { - struct list_head list; - lt_t release_time; + /* Servers to be released */ + struct list_head servers; + lt_t release_time; - struct list_head servers; + /* For membership in the domain */ + struct list_head list; + + /* For callbacks */ + server_domain_t *domain; struct hrtimer timer; struct hrtimer_start_on_info info; - - server_domain_t *domain; } server_release_heap_t; +/* + * A timer for managing server completions. Can be managed concurrently. + */ +typedef struct completion_timer { + int armed; /* Is the timer armed or not? Seperate from the timer + * so that it can be used to disarm a timer which + * is already firing. + */ + int cpu; /* CPU where the server is running. This is not the + * cpu on which the timer will fire. + */ + struct hrtimer timer; + struct hrtimer_start_on_info info; + struct server_domain *domain; /* For callbacks */ +} completion_timer_t; + +/* + * A proc directory entry which controls a group of servers. + */ +typedef struct server_proc { + struct proc_dir_entry *entry; + struct list_head list; + admit_server_t admit_server; /* Add a server from the entry */ + list_servers_t list_servers; /* List each server in the entry */ + stop_servers_t stop_servers; /* Disables all servers in the entry */ + char* page; /* Used internally by proc */ + int length; /* Used internally by proc */ +} server_proc_t; + /* * Initialize and exit servers */ -void server_init(server_t *server, int id, +void server_init(server_t *server, server_domain_t *domain, int id, lt_t wcet, lt_t period, int grouped); void server_destroy(server_t *server); @@ -137,7 +173,7 @@ void server_free(server_t *server); void server_domain_init(server_domain_t *domain, servers_released_t servers_released, server_completed_t server_completed, - int release_master, raw_spinlock_t* timer_lock); + int release_master, raw_spinlock_t* completion_lock); void server_domain_destroy(server_domain_t *domain); /* @@ -148,13 +184,12 @@ int add_server_release(server_t *server, server_domain_t *server_domain); /* * Runs a task on the server. */ -void server_run(server_t *server, struct task_struct *task, - server_domain_t *server_domain); +void server_run(server_t *server, struct task_struct *task); /* * Stops server execution. */ -void server_stop(server_t *server, server_domain_t *domain); +void server_stop(server_t *server); /* * Begins a server's next period. @@ -167,20 +202,18 @@ void server_release(server_t *server); void server_release_at(server_t *server, lt_t time); /* - * Call once for every server which should be printed - * out on a proc dir read. Should be called inside a list_servers_t - * method. + * Call once for every server which should be printed by list_servers. */ -void server_proc_read_single(server_t *server, int cpu, - struct proc_read_args *args); +void list_server(server_t *server, int cpu, server_proc_t *proc); /* * Create and destroy a proc dir entry with the given file name. */ -int server_proc_init(struct proc_dir_entry *proc_dir, char *file, - admit_server_t admit_server, - list_servers_t list_servers, - stop_servers_t stop_servers); -void server_proc_exit(struct proc_dir_entry *proc_dir, char *file); +server_proc_t* server_proc_init(server_domain_t *domain, + struct proc_dir_entry *proc_dir, char *file, + admit_server_t admit_server, + list_servers_t list_servers, + stop_servers_t stop_servers); +void server_proc_exit(server_proc_t *proc); #endif -- cgit v1.2.2