aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2016-07-20 07:16:57 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2016-07-20 07:42:41 -0400
commita77898c74f599af64b029bf97ca82bf23c29fcd5 (patch)
tree8bb4a2ee55c291304f7da34fe9598a520ff77deb
parent9a8d7e447bbd1525f9f9f4660977072219bbc726 (diff)
rtspin: add -T (use clock_nanosleep) option
This make rtspin use the regular Linux API for periodic activations instead of the LITMUS^RT-specifc sleep_next_period() API.
-rw-r--r--bin/rtspin.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c
index d33e9b3..498603f 100644
--- a/bin/rtspin.c
+++ b/bin/rtspin.c
@@ -62,6 +62,8 @@ const char *usage_msg =
62 " default w/o -S: periodic job releases\n" 62 " default w/o -S: periodic job releases\n"
63 " default if FILE is omitted: read from STDIN\n" 63 " default if FILE is omitted: read from STDIN\n"
64 "\n" 64 "\n"
65 " -T use clock_nanosleep() instead of sleep_next_period()\n"
66 "\n"
65 " -X PROTOCOL access a shared resource protected by a locking protocol\n" 67 " -X PROTOCOL access a shared resource protected by a locking protocol\n"
66 " -L CS-LENGTH simulate a critical section length of CS-LENGTH milliseconds\n" 68 " -L CS-LENGTH simulate a critical section length of CS-LENGTH milliseconds\n"
67 " -Q RESOURCE-ID access the resource identified by RESOURCE-ID\n" 69 " -Q RESOURCE-ID access the resource identified by RESOURCE-ID\n"
@@ -276,7 +278,7 @@ static void job(double exec_time, double program_end, int lock_od, double cs_len
276 } 278 }
277} 279}
278 280
279#define OPTSTR "p:c:wlveo:F:s:m:q:r:X:L:Q:iRu:Bhd:C:S::" 281#define OPTSTR "p:c:wlveo:F:s:m:q:r:X:L:Q:iRu:Bhd:C:S::T"
280int main(int argc, char** argv) 282int main(int argc, char** argv)
281{ 283{
282 int ret; 284 int ret;
@@ -310,6 +312,9 @@ int main(int argc, char** argv)
310 int sporadic = 0; /* trigger jobs sporadically? */ 312 int sporadic = 0; /* trigger jobs sporadically? */
311 int event_fd = -1; /* file descriptor for sporadic events */ 313 int event_fd = -1; /* file descriptor for sporadic events */
312 314
315 int linux_sleep = 0; /* use Linux API for periodic activations? */
316 lt_t next_release;
317
313 int verbose = 0; 318 int verbose = 0;
314 unsigned int job_no; 319 unsigned int job_no;
315 struct control_page* cp; 320 struct control_page* cp;
@@ -379,6 +384,9 @@ int main(int argc, char** argv)
379 "for STDIN."); 384 "for STDIN.");
380 } 385 }
381 break; 386 break;
387 case 'T':
388 linux_sleep = 1;
389 break;
382 case 'm': 390 case 'm':
383 nr_of_pages = atoi(optarg); 391 nr_of_pages = atoi(optarg);
384 break; 392 break;
@@ -576,6 +584,10 @@ int main(int argc, char** argv)
576 start = wctime(); 584 start = wctime();
577 } 585 }
578 586
587 if (cp)
588 next_release = cp->release + period;
589 else
590 next_release = litmus_clock() + period;
579 591
580 /* main job loop */ 592 /* main job loop */
581 cur_job = 0; 593 cur_job = 0;
@@ -645,7 +657,16 @@ int main(int argc, char** argv)
645 /* wait for periodic job activation (unless sporadic) */ 657 /* wait for periodic job activation (unless sporadic) */
646 if (!sporadic) { 658 if (!sporadic) {
647 /* periodic job activations */ 659 /* periodic job activations */
648 sleep_next_period(); 660 if (linux_sleep) {
661 /* Use vanilla Linux API. This looks to the
662 * active LITMUS^RT plugin like a
663 * self-suspension. */
664 lt_sleep_until(next_release);
665 next_release += period;
666 } else
667 /* Use LITMUS^RT API: some plugins optimize
668 * this by not actually suspending the task. */
669 sleep_next_period();
649 } 670 }
650 } 671 }
651 672