Skip to contentSkip to conversation

threadobj_set_schedparam and SCHED_OTHER on mercury

Xenomai Matthias Schneider 2 participants 5 messages May 22, 2014 – May 25, 2014

lore
Share & tools
lore
#0 lore raw

Hi,

Since commit 2d102939333201169493688dd91258164bd9737c
copperplate: more robustness for threadobj_set_schedparam()

threadobj_set_schedparam() seems no longer to allow SCHED_OTHER on mercury, due to prepare_rr_corespec() always returning SCHED_FIFO.

i.e. threadobj_set_schedparam( prio 0, SCHED_OTHER) does not work anymore.

Regards,
Matthias

#1 lore raw
Quoted 6 lines · Matthias Schneider

Hi,

Since commit
2d102939333201169493688dd91258164bd9737c
copperplate: more robustness for threadobj_set_schedparam()

Quoted 6 lines

threadobj_set_schedparam() seems no longer to allow SCHED_OTHER on mercury, due to prepare_rr_corespec() always returning SCHED_FIFO.

i.e. threadobj_set_schedparam( prio 0, SCHED_OTHER) does not work anymore.

This should help. With those latest changes, the issue with the priority range available for SCHED_RR with Cobalt should be fixed.

lib/copperplate/threadobj.c +3 -1
index 8792927..dc5c905 100644
@@ -1486,7 +1486,9 @@ int threadobj_set_schedparam(struct threadobj *thobj, int policy,
 	if (thobj->schedlock_depth > 0)
 		return __bt(-EPERM);
 
-	_policy = prepare_rr_corespec(thobj, policy, param_ex);
+	_policy = policy;
+	if (rr == SCHED_RR)
+		_policy = prepare_rr_corespec(thobj, policy, param_ex);
 	/*
 	 * NOTE: if the current thread suddently starves as a result
 	 * of switching itself to a scheduling class with no runtime
Signature · 1 line
Philippe.
#2 lore raw
Quoted 33 lines · Philippe Gerum
Quoted 6 lines · Matthias Schneider

Hi,

Since commit
2d102939333201169493688dd91258164bd9737c
copperplate: more robustness for threadobj_set_schedparam()

Quoted 7 lines

threadobj_set_schedparam() seems no longer to allow SCHED_OTHER on mercury, due to prepare_rr_corespec() always returning SCHED_FIFO.

i.e. threadobj_set_schedparam( prio 0, SCHED_OTHER) does not work anymore.

This should help. With those latest changes, the issue with the priority range available for SCHED_RR with Cobalt should be fixed.

lib/copperplate/threadobj.c +3 -1
index 8792927..dc5c905 100644
@@ -1486,7 +1486,9 @@ int threadobj_set_schedparam(struct threadobj
 *thobj, int policy,
      if (thobj->schedlock_depth > 0)
          return __bt(-EPERM);
 
-    _policy = prepare_rr_corespec(thobj, policy, param_ex);
+    _policy = policy;
+    if (rr == SCHED_RR)
+        _policy = prepare_rr_corespec(thobj, policy, param_ex);
      /*
       * NOTE: if the current thread suddently starves as a result
Quoted 2 lines

* of switching itself to a scheduling class with no runtime

Typo.

lib/copperplate/threadobj.c +3 -1
index 8792927..4515c9e 100644
@@ -1486,7 +1486,9 @@ int threadobj_set_schedparam(struct threadobj *thobj, int policy,
 	if (thobj->schedlock_depth > 0)
 		return __bt(-EPERM);
 
-	_policy = prepare_rr_corespec(thobj, policy, param_ex);
+	_policy = policy;
+	if (policy == SCHED_RR)
+		_policy = prepare_rr_corespec(thobj, policy, param_ex);
 	/*
 	 * NOTE: if the current thread suddently starves as a result
 	 * of switching itself to a scheduling class with no runtime
Signature · 1 line
Philippe.
#3 lore raw

----- Original Message -----

Quoted 60 lines

From: Philippe Gerum <[email protected]>
To: Matthias Schneider <[email protected]>; "[email protected]" <[email protected]> Cc:
Sent: Thursday, May 22, 2014 9:20 PM
Subject: Re: [Xenomai] threadobj_set_schedparam and SCHED_OTHER on mercury

Quoted 27 lines · Philippe Gerum
Quoted 6 lines · Matthias Schneider

Hi,

Since commit
  2d102939333201169493688dd91258164bd9737c
copperplate: more robustness for threadobj_set_schedparam()

Quoted 7 lines

threadobj_set_schedparam() seems no longer to allow SCHED_OTHER on mercury, due to prepare_rr_corespec() always returning SCHED_FIFO.

i.e. threadobj_set_schedparam( prio 0, SCHED_OTHER) does not work anymore.

This should help. With those latest changes, the issue with the priority range available for SCHED_RR with Cobalt should be fixed.

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c index 8792927..dc5c905 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -1486,7 +1486,9 @@ int threadobj_set_schedparam(struct threadobj *thobj, int policy,
      if (thobj->schedlock_depth > 0)
          return __bt(-EPERM);

Quoted 8 lines

-    _policy = prepare_rr_corespec(thobj, policy, param_ex); +    _policy = policy;
+    if (rr == SCHED_RR)
+        _policy = prepare_rr_corespec(thobj, policy, param_ex);
      /*
        * NOTE: if the current thread suddently starves as a result
        * of switching itself to a scheduling class with no runtime

Typo.

lib/copperplate/threadobj.c +3 -1
index 8792927..4515c9e 100644
@@ -1486,7 +1486,9 @@ int threadobj_set_schedparam(struct threadobj 
 *thobj, int policy,
       if (thobj->schedlock_depth > 0)
           return __bt(-EPERM);
 
-    _policy = prepare_rr_corespec(thobj, policy, param_ex);
+    _policy = policy;
+    if (policy == SCHED_RR)
 
+        _policy = prepare_rr_corespec(thobj, policy, param_ex);
       /*
Quoted 6 lines

      * NOTE: if the current thread suddently starves as a result
      * of switching itself to a scheduling class with no runtime

Signature · 1 line
Philippe.

The patch fixes my issue on mercury. I have not yet had the chance to verify cobalt. Are the number of priorities for SCHED_RT and SCHED_RR now both 257 on cobalt?

Thanks for the quick fix,

regards,
Matthias

#4 lore raw
Quoted 69 lines · Matthias Schneider

----- Original Message -----

Quoted 63 lines

From: Philippe Gerum <[email protected]>
To: Matthias Schneider <[email protected]>; "[email protected]" <[email protected]> Cc:
Sent: Thursday, May 22, 2014 9:20 PM
Subject: Re: [Xenomai] threadobj_set_schedparam and SCHED_OTHER on mercury

Quoted 27 lines · Philippe Gerum
Quoted 4 lines · Matthias Schneider

Hi,

Since commit

    2d102939333201169493688dd91258164bd9737c
Quoted 9 lines

copperplate: more robustness for threadobj_set_schedparam()

threadobj_set_schedparam() seems no longer to allow SCHED_OTHER on mercury, due to prepare_rr_corespec() always returning SCHED_FIFO.

i.e. threadobj_set_schedparam( prio 0, SCHED_OTHER) does not work anymore.

This should help. With those latest changes, the issue with the priority range available for SCHED_RR with Cobalt should be fixed.

  diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
  index 8792927..dc5c905 100644
  --- a/lib/copperplate/threadobj.c
  +++ b/lib/copperplate/threadobj.c
  @@ -1486,7 +1486,9 @@ int threadobj_set_schedparam(struct threadobj
  *thobj, int policy,
        if (thobj->schedlock_depth > 0)
            return __bt(-EPERM);
Quoted 8 lines
  -    _policy = prepare_rr_corespec(thobj, policy, param_ex);
  +    _policy = policy;
  +    if (rr == SCHED_RR)

+ _policy = prepare_rr_corespec(thobj, policy, param_ex);
/*
* NOTE: if the current thread suddently starves as a result
* of switching itself to a scheduling class with no runtime

Typo.

lib/copperplate/threadobj.c +3 -1
index 8792927..4515c9e 100644
@@ -1486,7 +1486,9 @@ int threadobj_set_schedparam(struct threadobj
 *thobj, int policy,
       if (thobj->schedlock_depth > 0)
           return __bt(-EPERM);
 
-    _policy = prepare_rr_corespec(thobj, policy, param_ex);
+    _policy = policy;
+    if (policy == SCHED_RR)
 
+        _policy = prepare_rr_corespec(thobj, policy, param_ex);
       /*

* NOTE: if the current thread suddently starves as a result
* of switching itself to a scheduling class with no runtime

Quoted 8 lines
Quoted 3 lines

--
Philippe.

The patch fixes my issue on mercury. I have not yet had the chance to verify cobalt. Are the number of priorities for SCHED_RT and SCHED_RR now both 257 on cobalt?

1..257 for SCHED_COBALT, 1..255 for SCHED_RR and SCHED_FIFO. Mercury still maps SCHED_RT to SCHED_COBALT, but will downgrade to SCHED_FIFO soon. Internal servers on highest priority levels will be switched to SCHED_COBALT in the same move.

Quoted 2 lines

Thanks for the quick fix,

You are welcome. I'll review the second freertos drop this coming week.

Signature · 1 line
Philippe.