aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/locking.c
diff options
context:
space:
mode:
Diffstat (limited to 'litmus/locking.c')
-rw-r--r--litmus/locking.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/litmus/locking.c b/litmus/locking.c
index e0e6c1dc6256..348a4be97cf9 100644
--- a/litmus/locking.c
+++ b/litmus/locking.c
@@ -68,7 +68,7 @@ static void destroy_generic_lock(obj_type_t type, void* obj)
68 lock->ops->deallocate(lock); 68 lock->ops->deallocate(lock);
69} 69}
70 70
71bool check_mask_valid(resource_mask_t mask) 71bool check_mask_valid(struct litmus_lock* l, resource_mask_t mask)
72{ 72{
73 // this should really check if all of the resources requested are 73 // this should really check if all of the resources requested are
74 // controlled by the dynamic group lock. this can be done with bitwise 74 // controlled by the dynamic group lock. this can be done with bitwise
@@ -76,35 +76,48 @@ bool check_mask_valid(resource_mask_t mask)
76 return true; 76 return true;
77} 77}
78 78
79asmlinkage long sys_dynamic_group_lock(int mask) 79asmlinkage long sys_dynamic_group_lock(resource_mask_t lock_ods)
80{ 80{
81 //long err = -EINVAL; 81 long err = -EINVAL;
82 struct od_table_entry* entry;
83 struct litmus_lock* l;
82 84
83 //TS_LOCK_START; 85 TS_LOCK_START;
84 86
85 //TS_LOCK_END; 87 entry = get_entry_for_od(ffs(lock_ods)-1);
88 if (entry && is_lock(entry)) {
89 l = get_lock(entry);
90 if (check_mask_valid(l, mask)){
91 TRACE_CUR("attempts to lock %d\n", lock_ods);
92 err = l->ops->dynamic_group_lock(l, lock_ods);
93 }
94 }
86 95
87 //return err; 96 TS_LOCK_END;
88 97
89 TRACE("Successfully called the dynamic group lock system call"); 98 return err;
90 printk(KERN_INFO "printk: Successfully called the dynamic group lock system call");
91 return -EINVAL;
92} 99}
93 100
94asmlinkage long sys_dynamic_group_unlock(resource_mask_t lock_ods) 101asmlinkage long sys_dynamic_group_unlock(resource_mask_t lock_ods)
95{ 102{
96 return 0; 103 long err = -EINVAL;
97} 104 struct od_table_entry* entry;
105 struct litmus_lock* l;
98 106
99/* 107 TS_UNLOCK_START;
100 * Point the new_od to the existing dynamic_group_lock pointed to in the entry 108
101 * for dgl_od. In so doing, update the metadata for the dgl so the masks are 109 entry = get_entry_for_od(ffs(lock_ods)-1);
102 * correct. 110 if (entry && is_lock(entry)) {
103 */ 111 l = get_lock(entry);
104asmlinkage long sys_dynamic_group_add(int dgl_od, int new_od) 112 if (check_mask_valid(l, mask)){
105{ 113 TRACE_CUR("attempts to unlock all resources in 0x%p\n",l);
106// long err = -EINVAL; 114 err = l->ops->dynamic_group_unlock(l, lock_ods);
107 return 0; 115 }
116 }
117
118 TS_UNLOCK_END;
119
120 return err;
108} 121}
109 122
110asmlinkage long sys_litmus_lock(int lock_od) 123asmlinkage long sys_litmus_lock(int lock_od)
@@ -113,10 +126,6 @@ asmlinkage long sys_litmus_lock(int lock_od)
113 struct od_table_entry* entry; 126 struct od_table_entry* entry;
114 struct litmus_lock* l; 127 struct litmus_lock* l;
115 128
116 TS_SYSCALL_IN_START;
117
118 TS_SYSCALL_IN_END;
119
120 TS_LOCK_START; 129 TS_LOCK_START;
121 130
122 entry = get_entry_for_od(lock_od); 131 entry = get_entry_for_od(lock_od);