diff options
author | Bryan Ward <bcw@cs.unc.edu> | 2012-08-07 11:04:48 -0400 |
---|---|---|
committer | Bryan Ward <bcw@cs.unc.edu> | 2013-04-16 14:32:36 -0400 |
commit | 5759d92625cfb9cfdf7defd3b5d8ebedc4f205cf (patch) | |
tree | 19243b50a3d2476226a4d0fe0bb304cea8e30fac | |
parent | 94edd278631ff219b4907322e620d9ffebceef4a (diff) |
Setup DGL system calls.
-rw-r--r-- | include/litmus/fdso.h | 8 | ||||
-rw-r--r-- | include/litmus/locking.h | 18 | ||||
-rw-r--r-- | include/litmus/unistd_32.h | 5 | ||||
-rw-r--r-- | include/litmus/unistd_64.h | 8 | ||||
-rw-r--r-- | litmus/fdso.c | 3 | ||||
-rw-r--r-- | litmus/locking.c | 39 | ||||
-rw-r--r-- | litmus/sched_psn_edf.c | 53 |
7 files changed, 128 insertions, 6 deletions
diff --git a/include/litmus/fdso.h b/include/litmus/fdso.h index f2115b83f1e4..82f88221f4f0 100644 --- a/include/litmus/fdso.h +++ b/include/litmus/fdso.h | |||
@@ -12,7 +12,9 @@ | |||
12 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | 14 | ||
15 | #define MAX_OBJECT_DESCRIPTORS 85 | 15 | #define MAX_OBJECT_DESCRIPTORS 32 |
16 | |||
17 | typedef unsigned int resource_mask_t; | ||
16 | 18 | ||
17 | typedef enum { | 19 | typedef enum { |
18 | MIN_OBJ_TYPE = 0, | 20 | MIN_OBJ_TYPE = 0, |
@@ -25,8 +27,10 @@ typedef enum { | |||
25 | DPCP_SEM = 4, | 27 | DPCP_SEM = 4, |
26 | 28 | ||
27 | PCP_SEM = 5, | 29 | PCP_SEM = 5, |
30 | |||
31 | DGL_SEM = 6, | ||
28 | 32 | ||
29 | MAX_OBJ_TYPE = 5 | 33 | MAX_OBJ_TYPE = 6 |
30 | } obj_type_t; | 34 | } obj_type_t; |
31 | 35 | ||
32 | struct inode_obj_id { | 36 | struct inode_obj_id { |
diff --git a/include/litmus/locking.h b/include/litmus/locking.h index 4d7b870cb443..e9998946e7de 100644 --- a/include/litmus/locking.h +++ b/include/litmus/locking.h | |||
@@ -3,6 +3,8 @@ | |||
3 | 3 | ||
4 | struct litmus_lock_ops; | 4 | struct litmus_lock_ops; |
5 | 5 | ||
6 | struct dynamic_group_lock_ops; | ||
7 | |||
6 | /* Generic base struct for LITMUS^RT userspace semaphores. | 8 | /* Generic base struct for LITMUS^RT userspace semaphores. |
7 | * This structure should be embedded in protocol-specific semaphores. | 9 | * This structure should be embedded in protocol-specific semaphores. |
8 | */ | 10 | */ |
@@ -25,4 +27,20 @@ struct litmus_lock_ops { | |||
25 | void (*deallocate)(struct litmus_lock*); | 27 | void (*deallocate)(struct litmus_lock*); |
26 | }; | 28 | }; |
27 | 29 | ||
30 | struct dynamic_group_lock { | ||
31 | struct dynamic_group_lock_ops *ops; | ||
32 | |||
33 | /* Probably useful for different RNLP variants. */ | ||
34 | int type; | ||
35 | }; | ||
36 | |||
37 | struct dynamic_group_lock_ops { | ||
38 | // Do we need open and close? | ||
39 | |||
40 | int (*lock)(struct dynamic_group_lock*); | ||
41 | int (*unlock)(struct dynamic_group_lock*); | ||
42 | |||
43 | void (*deallocate)(struct dynamic_group_lock*); | ||
44 | }; | ||
45 | |||
28 | #endif | 46 | #endif |
diff --git a/include/litmus/unistd_32.h b/include/litmus/unistd_32.h index 94264c27d9ac..1c59c92547c5 100644 --- a/include/litmus/unistd_32.h +++ b/include/litmus/unistd_32.h | |||
@@ -17,5 +17,8 @@ | |||
17 | #define __NR_wait_for_ts_release __LSC(9) | 17 | #define __NR_wait_for_ts_release __LSC(9) |
18 | #define __NR_release_ts __LSC(10) | 18 | #define __NR_release_ts __LSC(10) |
19 | #define __NR_null_call __LSC(11) | 19 | #define __NR_null_call __LSC(11) |
20 | #define __NR_dynamic_group_lock __LSC(12) | ||
21 | #define __NR_dynamic_group_unlock __LSC(13) | ||
22 | #define __NR_dynamic_group_add __LSC(14) | ||
20 | 23 | ||
21 | #define NR_litmus_syscalls 12 | 24 | #define NR_litmus_syscalls 15 |
diff --git a/include/litmus/unistd_64.h b/include/litmus/unistd_64.h index d5ced0d2642c..93ea10363b46 100644 --- a/include/litmus/unistd_64.h +++ b/include/litmus/unistd_64.h | |||
@@ -29,5 +29,11 @@ __SYSCALL(__NR_wait_for_ts_release, sys_wait_for_ts_release) | |||
29 | __SYSCALL(__NR_release_ts, sys_release_ts) | 29 | __SYSCALL(__NR_release_ts, sys_release_ts) |
30 | #define __NR_null_call __LSC(11) | 30 | #define __NR_null_call __LSC(11) |
31 | __SYSCALL(__NR_null_call, sys_null_call) | 31 | __SYSCALL(__NR_null_call, sys_null_call) |
32 | #define __NR_dynamic_group_lock __LSC(12) | ||
33 | __SYSCALL(__NR_dynamic_group_lock, sys_dynamic_group_lock) | ||
34 | #define __NR_dynamic_group_unlock __LSC(13) | ||
35 | __SYSCALL(__NR_dynamic_group_lock, sys_dynamic_group_unlock) | ||
36 | #define __NR_dynamic_group_add __LSC(14) | ||
37 | __SYSCALL(__NR_dynamic_group_add, sys_dynamic_group_add) | ||
32 | 38 | ||
33 | #define NR_litmus_syscalls 12 | 39 | #define NR_litmus_syscalls 15 |
diff --git a/litmus/fdso.c b/litmus/fdso.c index c4b450be4509..fdd9a6e805c7 100644 --- a/litmus/fdso.c +++ b/litmus/fdso.c | |||
@@ -27,6 +27,7 @@ static const struct fdso_ops* fdso_ops[] = { | |||
27 | &generic_lock_ops, /* MPCP_VS_SEM */ | 27 | &generic_lock_ops, /* MPCP_VS_SEM */ |
28 | &generic_lock_ops, /* DPCP_SEM */ | 28 | &generic_lock_ops, /* DPCP_SEM */ |
29 | &generic_lock_ops, /* PCP_SEM */ | 29 | &generic_lock_ops, /* PCP_SEM */ |
30 | &generic_lock_ops, /* RNLP_SEM */ | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | static int fdso_create(void** obj_ref, obj_type_t type, void* __user config) | 33 | static int fdso_create(void** obj_ref, obj_type_t type, void* __user config) |
@@ -238,7 +239,6 @@ static int do_sys_od_open(struct file* file, obj_type_t type, int id, | |||
238 | return idx; | 239 | return idx; |
239 | } | 240 | } |
240 | 241 | ||
241 | |||
242 | struct od_table_entry* get_entry_for_od(int od) | 242 | struct od_table_entry* get_entry_for_od(int od) |
243 | { | 243 | { |
244 | struct task_struct *t = current; | 244 | struct task_struct *t = current; |
@@ -252,7 +252,6 @@ struct od_table_entry* get_entry_for_od(int od) | |||
252 | return t->od_table + od; | 252 | return t->od_table + od; |
253 | } | 253 | } |
254 | 254 | ||
255 | |||
256 | asmlinkage long sys_od_open(int fd, int type, int obj_id, void* __user config) | 255 | asmlinkage long sys_od_open(int fd, int type, int obj_id, void* __user config) |
257 | { | 256 | { |
258 | int ret = 0; | 257 | int ret = 0; |
diff --git a/litmus/locking.c b/litmus/locking.c index 43d9aece2e74..6ddc22b7de11 100644 --- a/litmus/locking.c +++ b/litmus/locking.c | |||
@@ -68,6 +68,45 @@ 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 | ||
71 | bool check_mask_valid(resource_mask_t mask) | ||
72 | { | ||
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 | ||
75 | // magic, by observing that A->B <-> ~A|B | ||
76 | return true; | ||
77 | } | ||
78 | |||
79 | asmlinkage long sys_dynamic_group_lock(resource_mask_t mask) | ||
80 | { | ||
81 | //long err = -EINVAL; | ||
82 | |||
83 | //TS_LOCK_START; | ||
84 | |||
85 | //TS_LOCK_END; | ||
86 | |||
87 | //return err; | ||
88 | |||
89 | TRACE("Successfully called the dynamic group lock system call"); | ||
90 | printk("printk: Successfully called the dynamic group lock system call"); | ||
91 | return -EINVAL; | ||
92 | } | ||
93 | |||
94 | asmlinkage long sys_dynamic_group_unlock(resource_mask_t lock_ods) | ||
95 | { | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * Point the new_od to the existing dynamic_group_lock pointed to in the entry | ||
101 | * for dgl_od. In so doing, update the metadata for the dgl so the masks are | ||
102 | * correct. | ||
103 | */ | ||
104 | asmlinkage long sys_dynamic_group_add(int dgl_od, int new_od) | ||
105 | { | ||
106 | // long err = -EINVAL; | ||
107 | return 0; | ||
108 | } | ||
109 | |||
71 | asmlinkage long sys_litmus_lock(int lock_od) | 110 | asmlinkage long sys_litmus_lock(int lock_od) |
72 | { | 111 | { |
73 | long err = -EINVAL; | 112 | long err = -EINVAL; |
diff --git a/litmus/sched_psn_edf.c b/litmus/sched_psn_edf.c index 65c85a3a4c64..ce97b73829bf 100644 --- a/litmus/sched_psn_edf.c +++ b/litmus/sched_psn_edf.c | |||
@@ -405,10 +405,37 @@ struct fmlp_semaphore { | |||
405 | wait_queue_head_t wait; | 405 | wait_queue_head_t wait; |
406 | }; | 406 | }; |
407 | 407 | ||
408 | struct dgl_semaphore { | ||
409 | struct dynamic_group_lock dynamic_group_lock; | ||
410 | |||
411 | /* bitmask of resources that are currently locked. */ | ||
412 | resource_mask_t locked; | ||
413 | |||
414 | /* bitmask of resources in the file descriptor table that are controlled by | ||
415 | * this dgl_semaphore. | ||
416 | */ | ||
417 | resource_mask_t dgl_resources; | ||
418 | |||
419 | /* There can be no more than $m$ resource holders, because under | ||
420 | * partitioned scheduling, the resource holders are priority boosted, and | ||
421 | * it is impossible to have $>m$ boosted jobs. | ||
422 | */ | ||
423 | unsigned int resource_holders; | ||
424 | |||
425 | /* FIFO queue of waiting tasks */ | ||
426 | wait_queue_head_t wait; | ||
427 | }; | ||
428 | |||
408 | static inline struct fmlp_semaphore* fmlp_from_lock(struct litmus_lock* lock) | 429 | static inline struct fmlp_semaphore* fmlp_from_lock(struct litmus_lock* lock) |
409 | { | 430 | { |
410 | return container_of(lock, struct fmlp_semaphore, litmus_lock); | 431 | return container_of(lock, struct fmlp_semaphore, litmus_lock); |
411 | } | 432 | } |
433 | |||
434 | static inline struct dgl_semaphore* dgl_from_lock(struct dynamic_group_lock* dgl) | ||
435 | { | ||
436 | return container_of(dgl, struct dgl_semaphore, dynamic_group_lock); | ||
437 | } | ||
438 | |||
412 | int psnedf_fmlp_lock(struct litmus_lock* l) | 439 | int psnedf_fmlp_lock(struct litmus_lock* l) |
413 | { | 440 | { |
414 | struct task_struct* t = current; | 441 | struct task_struct* t = current; |
@@ -534,6 +561,11 @@ void psnedf_fmlp_free(struct litmus_lock* lock) | |||
534 | kfree(fmlp_from_lock(lock)); | 561 | kfree(fmlp_from_lock(lock)); |
535 | } | 562 | } |
536 | 563 | ||
564 | void psnedf_dgl_free(struct dynamic_group_lock* dgl) | ||
565 | { | ||
566 | kfree(dgl_from_lock(dgl)); | ||
567 | } | ||
568 | |||
537 | static struct litmus_lock_ops psnedf_fmlp_lock_ops = { | 569 | static struct litmus_lock_ops psnedf_fmlp_lock_ops = { |
538 | .close = psnedf_fmlp_close, | 570 | .close = psnedf_fmlp_close, |
539 | .lock = psnedf_fmlp_lock, | 571 | .lock = psnedf_fmlp_lock, |
@@ -541,6 +573,12 @@ static struct litmus_lock_ops psnedf_fmlp_lock_ops = { | |||
541 | .deallocate = psnedf_fmlp_free, | 573 | .deallocate = psnedf_fmlp_free, |
542 | }; | 574 | }; |
543 | 575 | ||
576 | //static struct dynamic_group_lock_ops psnedf_dgl_lock_ops = { | ||
577 | // .lock = psnedf_dgl_lock, | ||
578 | // .unlock = psnedf_dgl_unlock, | ||
579 | // .deallocate = psnedf_dgl_free, | ||
580 | //} | ||
581 | |||
544 | static struct litmus_lock* psnedf_new_fmlp(void) | 582 | static struct litmus_lock* psnedf_new_fmlp(void) |
545 | { | 583 | { |
546 | struct fmlp_semaphore* sem; | 584 | struct fmlp_semaphore* sem; |
@@ -556,6 +594,21 @@ static struct litmus_lock* psnedf_new_fmlp(void) | |||
556 | return &sem->litmus_lock; | 594 | return &sem->litmus_lock; |
557 | } | 595 | } |
558 | 596 | ||
597 | static struct dynamic_group_lock* psnedf_new_dgl(void) | ||
598 | { | ||
599 | struct dgl_semaphore* sem; | ||
600 | |||
601 | sem = kmalloc(sizeof(*sem), GFP_KERNEL); | ||
602 | if (!sem) | ||
603 | return NULL; | ||
604 | |||
605 | sem->resource_holders = 0; | ||
606 | sem->dgl_resources = 0; | ||
607 | init_waitqueue_head(&sem->wait); | ||
608 | //sem->dynamic_group_lock.ops = &psnedf_dgl_lock_ops; | ||
609 | return &sem->dynamic_group_lock; | ||
610 | } | ||
611 | |||
559 | /* **** lock constructor **** */ | 612 | /* **** lock constructor **** */ |
560 | 613 | ||
561 | 614 | ||