aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2011-07-23 19:41:23 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2011-07-23 19:41:23 -0400
commit1a7a9033098f58708ce2b98495b0ee73c4504130 (patch)
treea89f6550a6ca767fad88afc0899ccdb85686d29a
parent40b52955999d06d8b526dc166094e0d592810fa7 (diff)
Add locking protocol name <--> id translation
-rw-r--r--include/litmus.h3
-rw-r--r--src/litmus.c39
2 files changed, 42 insertions, 0 deletions
diff --git a/include/litmus.h b/include/litmus.h
index ec548b1..2b6b374 100644
--- a/include/litmus.h
+++ b/include/litmus.h
@@ -58,6 +58,9 @@ typedef enum {
58 OMLP_SEM = 5, 58 OMLP_SEM = 5,
59} obj_type_t; 59} obj_type_t;
60 60
61int lock_protocol_for_name(const char* name);
62const char* name_for_lock_protocol(int id);
63
61int od_openx(int fd, obj_type_t type, int obj_id, void* config); 64int od_openx(int fd, obj_type_t type, int obj_id, void* config);
62int od_close(int od); 65int od_close(int od);
63 66
diff --git a/src/litmus.c b/src/litmus.c
index d478ffc..a1ce873 100644
--- a/src/litmus.c
+++ b/src/litmus.c
@@ -10,6 +10,45 @@
10#include "litmus.h" 10#include "litmus.h"
11#include "internal.h" 11#include "internal.h"
12 12
13#define LP(name) {name ## _SEM, #name}
14
15static struct {
16 int id;
17 const char* name;
18} protocol[] = {
19 LP(FMLP),
20 LP(SRP),
21 LP(MPCP),
22 LP(MPCP_VS),
23 LP(DPCP),
24 LP(OMLP),
25};
26
27#define NUM_PROTOS (sizeof(protocol)/sizeof(protocol[0]))
28
29int lock_protocol_for_name(const char* name)
30{
31 int i;
32
33 for (i = 0; i < NUM_PROTOS; i++)
34 if (strcmp(name, protocol[i].name) == 0)
35 return protocol[i].id;
36
37 return -1;
38}
39
40const char* name_for_lock_protocol(int id)
41{
42 int i;
43
44 for (i = 0; i < NUM_PROTOS; i++)
45 if (protocol[i].id == id)
46 return protocol[i].name;
47
48 return "<UNKNOWN>";
49}
50
51
13void show_rt_param(struct rt_task* tp) 52void show_rt_param(struct rt_task* tp)
14{ 53{
15 printf("rt params:\n\t" 54 printf("rt params:\n\t"