This is mainly to put back the main thread as SCHED_OTHER
when doing disk I/O. (stats dump...)
In some circumstances, disk I/O within an RT task might hang the
system. (deadlock)
---
 testcases/realtime/include/librttest.h |    5 +++++
 testcases/realtime/lib/librttest.c     |   13 +++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/testcases/realtime/include/librttest.h 
b/testcases/realtime/include/librttest.h
index b56f81e..bb30ee7 100644
--- a/testcases/realtime/include/librttest.h
+++ b/testcases/realtime/include/librttest.h
@@ -302,6 +302,11 @@ int set_thread_priority(pthread_t pthread, int prio);
  */
 int set_priority(int prio);
 
+/* Change the priority of the current context (usually called from main())
+ * and its policy to SCHED_OTHER
+ */
+int set_priority_other(int prio);
+
 /* all_threads_quit: signal all threads to quit */
 void all_threads_quit(void);
 
diff --git a/testcases/realtime/lib/librttest.c 
b/testcases/realtime/lib/librttest.c
index ed1f097..c82fb95 100644
--- a/testcases/realtime/lib/librttest.c
+++ b/testcases/realtime/lib/librttest.c
@@ -267,6 +267,19 @@ int set_priority(int prio)
        return ret;
 }
 
+int set_priority_other(int prio)
+{
+       struct sched_param sp;
+       int ret = 0;
+
+       sp.sched_priority = prio;
+       if (sched_setscheduler(0, SCHED_OTHER, &sp) != 0) {
+               perror("sched_setscheduler");
+               ret = -1;
+       }
+       return ret;
+}
+
 void join_thread(int i)
 {
        struct thread *p, *t = NULL;
-- 
1.5.5.GIT


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to