aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTanya Amert <tamert@cs.unc.edu>2020-10-20 19:13:24 -0400
committerTanya Amert <tamert@cs.unc.edu>2020-10-20 19:13:24 -0400
commit142eaff3b0ebb0a681f94832599af12549f809af (patch)
tree71642300b6415cd1db322b934a4716e314cdd011
parentea6838de3c4c0b2abd7ba8f058ba77a924a38a6f (diff)
Added support for suspending for per-access forbidden zones
under EXT-RES scheduling with the global OMLP. Note that this assumes the caller already holds the lock.
-rw-r--r--bin/rtspin.c13
-rw-r--r--include/litmus.h6
-rw-r--r--src/syscalls.c8
3 files changed, 24 insertions, 3 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c
index fb7f13f..70b5528 100644
--- a/bin/rtspin.c
+++ b/bin/rtspin.c
@@ -82,6 +82,7 @@ const char *usage_msg =
82 " -X PROTOCOL access a shared resource protected by a locking protocol\n" 82 " -X PROTOCOL access a shared resource protected by a locking protocol\n"
83 " -L CS-LENGTH simulate a critical section length of CS-LENGTH milliseconds\n" 83 " -L CS-LENGTH simulate a critical section length of CS-LENGTH milliseconds\n"
84 " -Q RESOURCE-ID access the resource identified by RESOURCE-ID\n" 84 " -Q RESOURCE-ID access the resource identified by RESOURCE-ID\n"
85 " -Z enable checking for forbidden zones after locking a resource\n"
85 "\n" 86 "\n"
86 "Units:\n" 87 "Units:\n"
87 " WCET and PERIOD are expected in milliseconds.\n" 88 " WCET and PERIOD are expected in milliseconds.\n"
@@ -298,7 +299,7 @@ static int generate_output(int output_fd)
298 return written == len; 299 return written == len;
299} 300}
300 301
301static void job(double exec_time, double program_end, int lock_od, double cs_length) 302static void job(double exec_time, double program_end, int lock_od, double cs_length, int check_fz)
302{ 303{
303 double chunk1, chunk2; 304 double chunk1, chunk2;
304 305
@@ -312,6 +313,8 @@ static void job(double exec_time, double program_end, int lock_od, double cs_len
312 313
313 /* critical section */ 314 /* critical section */
314 litmus_lock(lock_od); 315 litmus_lock(lock_od);
316 if (check_fz)
317 litmus_access_forbidden_zone_check(lock_od, s2ns(cs_length));
315 loop_for(cs_length, program_end + 1); 318 loop_for(cs_length, program_end + 1);
316 litmus_unlock(lock_od); 319 litmus_unlock(lock_od);
317 320
@@ -336,7 +339,7 @@ static lt_t choose_inter_arrival_time_ns(
336 return ms2ns(iat_ms); 339 return ms2ns(iat_ms);
337} 340}
338 341
339#define OPTSTR "p:c:wlveo:s:m:q:r:X:L:Q:iRu:U:Bhd:C:S::O::TD:E:A:a:" 342#define OPTSTR "p:c:wlveo:s:m:q:r:X:L:Q:ZiRu:U:Bhd:C:S::O::TD:E:A:a:"
340 343
341int main(int argc, char** argv) 344int main(int argc, char** argv)
342{ 345{
@@ -402,6 +405,7 @@ int main(int argc, char** argv)
402 const char *lock_namespace = "./rtspin-locks"; 405 const char *lock_namespace = "./rtspin-locks";
403 int protocol = -1; 406 int protocol = -1;
404 double cs_length = 1; /* millisecond */ 407 double cs_length = 1; /* millisecond */
408 int check_fz = 0;
405 409
406 progname = argv[0]; 410 progname = argv[0];
407 411
@@ -530,6 +534,9 @@ int main(int argc, char** argv)
530 resource_id = want_non_negative_int(optarg, "-Q"); 534 resource_id = want_non_negative_int(optarg, "-Q");
531 535
532 break; 536 break;
537 case 'Z':
538 check_fz = 1;
539 break;
533 case 'v': 540 case 'v':
534 verbose = 1; 541 verbose = 1;
535 break; 542 break;
@@ -803,7 +810,7 @@ int main(int argc, char** argv)
803 (acet * 1000 / wcet_ms) * 100); 810 (acet * 1000 / wcet_ms) * 100);
804 811
805 /* burn cycles */ 812 /* burn cycles */
806 job(acet, start + duration, lock_od, cs_length * 0.001); 813 job(acet, start + duration, lock_od, cs_length * 0.001, check_fz);
807 814
808 if (want_output) { 815 if (want_output) {
809 /* generate some output at end of job */ 816 /* generate some output at end of job */
diff --git a/include/litmus.h b/include/litmus.h
index a50f996..8ccd0b7 100644
--- a/include/litmus.h
+++ b/include/litmus.h
@@ -235,6 +235,12 @@ int litmus_open_lock(obj_type_t protocol, int lock_id, const char* name_space,
235 */ 235 */
236int litmus_lock(int od); 236int litmus_lock(int od);
237/** 237/**
238 * Access protected resource (wait if in forbidden zone)
239 * @param od Object descriptor obtained by litmus_open_lock()
240 * @return 0 iff the resource access was granted successfully
241 */
242int litmus_access_forbidden_zone_check(int od, lt_t fz_len);
243/**
238 * Release lock 244 * Release lock
239 * @param od Object descriptor obtained by litmus_open_lock() 245 * @param od Object descriptor obtained by litmus_open_lock()
240 * @return 0 iff the lock was released successfully 246 * @return 0 iff the lock was released successfully
diff --git a/src/syscalls.c b/src/syscalls.c
index 70c67dd..9a1a1c3 100644
--- a/src/syscalls.c
+++ b/src/syscalls.c
@@ -67,6 +67,14 @@ int litmus_lock(int od)
67 return litmus_syscall(LRT_litmus_lock, od); 67 return litmus_syscall(LRT_litmus_lock, od);
68} 68}
69 69
70int litmus_access_forbidden_zone_check(int od, lt_t fz_len)
71{
72 union litmus_syscall_args args;
73 args.access_forbidden_zone_check.sem_od = od;
74 args.access_forbidden_zone_check.fz_len = fz_len;
75 return litmus_syscall(LRT_access_forbidden_zone_check, (unsigned long) &args);
76}
77
70int litmus_unlock(int od) 78int litmus_unlock(int od)
71{ 79{
72 return litmus_syscall(LRT_litmus_unlock, od); 80 return litmus_syscall(LRT_litmus_unlock, od);