From aae25e0770ade4083937c7443448cb3f0023b10a Mon Sep 17 00:00:00 2001 From: Sven Dziadek Date: Sat, 14 Apr 2012 16:19:37 +0200 Subject: P-FP: port P-FP plugin used in B. Brandenburg's dissertation (branch bbb-diss) I took the unchanged code but removed references to OMLP which was and is not implemented tests: changed so that they work for P-FP --- bin/rtspin.c | 10 ++++++++-- include/litmus.h | 19 +++++++++++++++---- src/litmus.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- tests/locks.c | 8 ++++---- 4 files changed, 73 insertions(+), 14 deletions(-) diff --git a/bin/rtspin.c b/bin/rtspin.c index ae76941..1244073 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c @@ -161,7 +161,7 @@ static int job(double exec_time, double program_end) } } -#define OPTSTR "p:c:wlveo:f:s:" +#define OPTSTR "p:c:wlveo:f:s:q:" int main(int argc, char** argv) { @@ -169,6 +169,7 @@ int main(int argc, char** argv) lt_t wcet; lt_t period; double wcet_ms, period_ms; + unsigned int priority = 0; int migrate = 0; int cpu = 0; int opt; @@ -194,6 +195,11 @@ int main(int argc, char** argv) cpu = atoi(optarg); migrate = 1; break; + case 'q': + priority = atoi(optarg); + if (priority == 0 || priority > LITMUS_MAX_PRIORITY) + usage("Invalid priority."); + break; case 'c': class = str2class(optarg); if (class == -1) @@ -274,7 +280,7 @@ int main(int argc, char** argv) bail_out("could not migrate to target partition"); } - ret = sporadic_task_ns(wcet, period, 0, cpu, class, + ret = sporadic_task_ns(wcet, period, 0, cpu, priority, class, want_enforcement ? PRECISE_ENFORCEMENT : NO_ENFORCEMENT, migrate); diff --git a/include/litmus.h b/include/litmus.h index 4c85d28..2357da9 100644 --- a/include/litmus.h +++ b/include/litmus.h @@ -32,27 +32,37 @@ int get_rt_task_param(pid_t pid, struct rt_task* param); /* times are given in ms */ int sporadic_task( lt_t e, lt_t p, lt_t phase, - int partition, task_class_t cls, + int partition, unsigned int priority, + task_class_t cls, budget_policy_t budget_policy, int set_cpu_set); /* times are given in ns */ int sporadic_task_ns( lt_t e, lt_t p, lt_t phase, - int cpu, task_class_t cls, + int cpu, unsigned int priority, + task_class_t cls, budget_policy_t budget_policy, int set_cpu_set); /* budget enforcement off by default in these macros */ #define sporadic_global(e, p) \ - sporadic_task(e, p, 0, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0) + sporadic_task(e, p, 0, 0, LITMUS_MAX_PRIORITY-1, \ + RT_CLASS_SOFT, NO_ENFORCEMENT, 0) #define sporadic_partitioned(e, p, cpu) \ - sporadic_task(e, p, 0, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1) + sporadic_task(e, p, 0, cpu, LITMUS_MAX_PRIORITY-1, \ + RT_CLASS_SOFT, NO_ENFORCEMENT, 1) /* file descriptor attached shared objects support */ typedef enum { FMLP_SEM = 0, SRP_SEM = 1, + MPCP_SEM = 2, + MPCP_VS_SEM = 3, + DPCP_SEM = 4, } obj_type_t; +int lock_protocol_for_name(const char* name); +const char* name_for_lock_protocol(int id); + int od_openx(int fd, obj_type_t type, int obj_id, void* config); int od_close(int od); @@ -96,6 +106,7 @@ task_class_t str2class(const char* str); /* non-preemptive section support */ void enter_np(void); void exit_np(void); +int exit_np_trace(void); int requested_to_preempt(void); /* task system support */ diff --git a/src/litmus.c b/src/litmus.c index d3cc6bb..9afe7a2 100644 --- a/src/litmus.c +++ b/src/litmus.c @@ -10,6 +10,45 @@ #include "litmus.h" #include "internal.h" +#define LP(name) {name ## _SEM, #name} + +static struct { + int id; + const char* name; +} protocol[] = { + LP(FMLP), + LP(SRP), + LP(MPCP), + LP(MPCP_VS), + {MPCP_VS_SEM, "MPCP-VS"}, + LP(DPCP), +}; + +#define NUM_PROTOS (sizeof(protocol)/sizeof(protocol[0])) + +int lock_protocol_for_name(const char* name) +{ + int i; + + for (i = 0; i < NUM_PROTOS; i++) + if (strcmp(name, protocol[i].name) == 0) + return protocol[i].id; + + return -1; +} + +const char* name_for_lock_protocol(int id) +{ + int i; + + for (i = 0; i < NUM_PROTOS; i++) + if (protocol[i].id == id) + return protocol[i].name; + + return ""; +} + + void show_rt_param(struct rt_task* tp) { printf("rt params:\n\t" @@ -42,16 +81,18 @@ int be_migrate_to(int target_cpu) } int sporadic_task(lt_t e, lt_t p, lt_t phase, - int cpu, task_class_t cls, + int cpu, unsigned int priority, + task_class_t cls, budget_policy_t budget_policy, int set_cpu_set) { return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, - cpu, cls, budget_policy, set_cpu_set); + cpu, priority, cls, budget_policy, set_cpu_set); } int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, - int cpu, task_class_t cls, - budget_policy_t budget_policy, int set_cpu_set) + int cpu, unsigned int priority, + task_class_t cls, + budget_policy_t budget_policy, int set_cpu_set) { struct rt_task param; int ret; @@ -67,6 +108,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, param.cls = cls; param.phase = phase; param.budget_policy = budget_policy; + param.priority = priority; if (set_cpu_set) { ret = be_migrate_to(cpu); diff --git a/tests/locks.c b/tests/locks.c index 65b932a..d7ebfe2 100644 --- a/tests/locks.c +++ b/tests/locks.c @@ -6,7 +6,7 @@ #include "litmus.h" -TESTCASE(not_lock_fmlp_be, GSN_EDF | PSN_EDF, +TESTCASE(not_lock_fmlp_be, GSN_EDF | PSN_EDF | P_FP, "don't let best-effort tasks lock FMLP semaphores") { int fd, od; @@ -29,7 +29,7 @@ TESTCASE(not_lock_fmlp_be, GSN_EDF | PSN_EDF, } -TESTCASE(not_lock_srp_be, PSN_EDF, +TESTCASE(not_lock_srp_be, PSN_EDF | P_FP, "don't let best-effort tasks open SRP semaphores") { int fd, od; @@ -46,7 +46,7 @@ TESTCASE(not_lock_srp_be, PSN_EDF, } -TESTCASE(lock_srp, PSN_EDF, +TESTCASE(lock_srp, PSN_EDF | P_FP, "SRP acquisition and release") { int fd, od; @@ -78,7 +78,7 @@ TESTCASE(lock_srp, PSN_EDF, } -TESTCASE(lock_fmlp, PSN_EDF | GSN_EDF, +TESTCASE(lock_fmlp, PSN_EDF | GSN_EDF | P_FP, "FMLP acquisition and release") { int fd, od; -- cgit v1.2.2