aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2010-07-12 13:03:42 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2010-08-03 12:43:46 -0400
commit88fed09b126f1b2e8d85fc834e09b734661b539c (patch)
treecfdde9e4656f0f0316fc2e393edc4bda2b4c2cae
parent136a08dbe8c28e751b01e932420f715edb229f6b (diff)
Restructure pi_semaphore struct for generic inheritance framework.
First patch in a series to implement a generic priority inheritance framework that can be used by semaphores that use priority inheritance. This patch makes pi_semaphore a 'base class' for pi-protocols. pi_semaphore is updated to include a pi_sem_record field named stack_node. This stack_node is a linked-list node that a task holding the pi_semaphore instance adds to their semaphore stack. Note that the task's semaphore stack (or linked-list) simply chains stack_node's of held semaphores into a single linked-list. This is safe since there is only one semaphore holder at any given moment. Finally, FMLP-specific data members out to child class fmlp_semaphore.
-rw-r--r--include/litmus/fdso.h2
-rw-r--r--include/litmus/rt_param.h22
-rw-r--r--include/litmus/sched_plugin.h29
-rw-r--r--litmus/Kconfig8
4 files changed, 56 insertions, 5 deletions
diff --git a/include/litmus/fdso.h b/include/litmus/fdso.h
index 61f1b5baf42c..b0e62a9098bd 100644
--- a/include/litmus/fdso.h
+++ b/include/litmus/fdso.h
@@ -62,7 +62,7 @@ static inline void* od_lookup(int od, obj_type_t type)
62 return e && e->obj->type == type ? e->obj->obj : NULL; 62 return e && e->obj->type == type ? e->obj->obj : NULL;
63} 63}
64 64
65#define lookup_fmlp_sem(od)((struct pi_semaphore*) od_lookup(od, FMLP_SEM)) 65#define lookup_fmlp_sem(od)((struct fmlp_semaphore*) od_lookup(od, FMLP_SEM))
66#define lookup_srp_sem(od) ((struct srp_semaphore*) od_lookup(od, SRP_SEM)) 66#define lookup_srp_sem(od) ((struct srp_semaphore*) od_lookup(od, SRP_SEM))
67#define lookup_ics(od) ((struct ics*) od_lookup(od, ICS_ID)) 67#define lookup_ics(od) ((struct ics*) od_lookup(od, ICS_ID))
68 68
diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h
index a7a183f34a80..6f40b52f0802 100644
--- a/include/litmus/rt_param.h
+++ b/include/litmus/rt_param.h
@@ -92,6 +92,28 @@ struct rt_job {
92 unsigned int job_no; 92 unsigned int job_no;
93}; 93};
94 94
95#ifdef CONFIG_PI_SEMAPHORES
96/* Record for storing a held lock and associated priority inheritance.
97 * Records are stored in a linked-list stack to support priority
98 * inheritance of nested critical sections.
99 *
100 * When strung together in a stack, nodes provide a record
101 * of currently held semaphores and order in which they were
102 * acquired.
103 */
104struct pi_sem_record {
105 /* Pointer to inheritance-donating job.
106 * May be set to "self" if there is no active
107 * inheritance from this semaphore.
108 */
109 struct task_struct *inh_task;
110
111 struct list_head list;
112};
113
114typedef struct pi_sem_record pi_sem_record_t;
115#endif
116
95struct pfair_param; 117struct pfair_param;
96 118
97/* RT task parameters for scheduling extensions 119/* RT task parameters for scheduling extensions
diff --git a/include/litmus/sched_plugin.h b/include/litmus/sched_plugin.h
index 9c1c9f28ba79..071e809564b2 100644
--- a/include/litmus/sched_plugin.h
+++ b/include/litmus/sched_plugin.h
@@ -7,6 +7,7 @@
7 7
8#include <linux/sched.h> 8#include <linux/sched.h>
9 9
10#ifdef CONFIG_PI_SEMAPHORES
10/* struct for semaphore with priority inheritance */ 11/* struct for semaphore with priority inheritance */
11struct pi_semaphore { 12struct pi_semaphore {
12 atomic_t count; 13 atomic_t count;
@@ -17,10 +18,29 @@ struct pi_semaphore {
17 struct task_struct *task; 18 struct task_struct *task;
18 struct task_struct* cpu_task[NR_CPUS]; 19 struct task_struct* cpu_task[NR_CPUS];
19 } hp; 20 } hp;
21
22 /* lock stack */
23 struct pi_sem_record stack_node;
24};
25
26static inline struct pi_semaphore* to_pi(void *sem) {
27 return (struct pi_semaphore*)sem;
28}
29#endif
30
31#ifdef CONFIG_FMLP
32struct fmlp_semaphore {
33 struct pi_semaphore pi; /* must always be first. */
34
20 /* current lock holder */ 35 /* current lock holder */
21 struct task_struct *holder; 36 struct task_struct *holder;
22}; 37};
23 38
39static inline struct fmlp_semaphore* to_fmlp(struct pi_semaphore* sem) {
40 return (struct fmlp_semaphore*)sem;
41}
42#endif
43
24/************************ setup/tear down ********************/ 44/************************ setup/tear down ********************/
25 45
26typedef long (*activate_plugin_t) (void); 46typedef long (*activate_plugin_t) (void);
@@ -63,6 +83,7 @@ typedef void (*task_block_t) (struct task_struct *task);
63 */ 83 */
64typedef void (*task_exit_t) (struct task_struct *); 84typedef void (*task_exit_t) (struct task_struct *);
65 85
86#ifdef CONFIG_PI_SEMAPHORES
66/* Called when the new_owner is released from the wait queue 87/* Called when the new_owner is released from the wait queue
67 * it should now inherit the priority from sem, _before_ it gets readded 88 * it should now inherit the priority from sem, _before_ it gets readded
68 * to any queue 89 * to any queue
@@ -79,7 +100,7 @@ typedef long (*return_priority_t) (struct pi_semaphore *sem);
79 * priority is higher than that of the current holder. 100 * priority is higher than that of the current holder.
80 */ 101 */
81typedef long (*pi_block_t) (struct pi_semaphore *sem, struct task_struct *t); 102typedef long (*pi_block_t) (struct pi_semaphore *sem, struct task_struct *t);
82 103#endif
83 104
84 105
85 106
@@ -124,9 +145,9 @@ struct sched_plugin {
124#ifdef CONFIG_FMLP 145#ifdef CONFIG_FMLP
125 /* priority inheritance */ 146 /* priority inheritance */
126 unsigned int fmlp_active; 147 unsigned int fmlp_active;
127 inherit_priority_t inherit_priority; 148 inherit_priority_t fmlp_inherit_priority;
128 return_priority_t return_priority; 149 return_priority_t fmlp_return_priority;
129 pi_block_t pi_block; 150 pi_block_t fmlp_pi_block;
130#endif 151#endif
131} __attribute__ ((__aligned__(SMP_CACHE_BYTES))); 152} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
132 153
diff --git a/litmus/Kconfig b/litmus/Kconfig
index 9888589ef126..e00887e672df 100644
--- a/litmus/Kconfig
+++ b/litmus/Kconfig
@@ -58,9 +58,17 @@ config SRP
58 Say Yes if you want FMLP local long critical section 58 Say Yes if you want FMLP local long critical section
59 synchronization support. 59 synchronization support.
60 60
61config PI_SEMAPHORES
62 bool "Semaphores with Priority Inheritance"
63 default n
64 help
65 Generalized support for all Litmus priority inheriting semaphore
66 protocols.
67
61config FMLP 68config FMLP
62 bool "FMLP support" 69 bool "FMLP support"
63 depends on NP_SECTION 70 depends on NP_SECTION
71 depends on PI_SEMAPHORES
64 default n 72 default n
65 help 73 help
66 Include support for deterministic multiprocessor real-time 74 Include support for deterministic multiprocessor real-time