Fix an issue where libthread_xu was not accepting the full priority
authorMatthew Dillon <dillon@dragonflybsd.org>
Tue, 15 Jul 2008 01:18:53 +0000 (01:18 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Tue, 15 Jul 2008 01:18:53 +0000 (01:18 +0000)
range returned by sched_get_priority_{min,max}(), causing firefox
to assert.

Reported-by: Jordan Gordeev <jgordeev@dir.bg>
Tested-by: walt <wa1ter@myrealbox.com>
lib/libthread_xu/thread/thr_attr.c
lib/libthread_xu/thread/thr_mutex_protocol.c
lib/libthread_xu/thread/thr_private.h

index bf69089..a778c74 100644 (file)
@@ -30,7 +30,7 @@
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $DragonFly: src/lib/libthread_xu/thread/thr_attr.c,v 1.8 2007/05/03 23:08:34 dillon Exp $
+ * $DragonFly: src/lib/libthread_xu/thread/thr_attr.c,v 1.9 2008/07/15 01:18:53 dillon Exp $
  */
 
 #include "namespace.h"
@@ -380,13 +380,17 @@ _pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *para
                ret = EINVAL;
        else if (param == NULL) {
                ret = ENOTSUP;
-       } else if ((param->sched_priority < THR_MIN_PRIORITY) ||
-           (param->sched_priority > THR_MAX_PRIORITY)) {
-               /* Return an unsupported value error. */
-               ret = ENOTSUP;
-       } else
-               (*attr)->prio = param->sched_priority;
-
+       } else {
+               int minv = sched_get_priority_min((*attr)->sched_policy);
+               int maxv = sched_get_priority_max((*attr)->sched_policy);
+               if (minv == -1 || maxv == -1 ||
+                   param->sched_priority < minv ||
+                   param->sched_priority > maxv) {
+                       ret = ENOTSUP;
+               } else {
+                       (*attr)->prio = param->sched_priority;
+               }
+       }
        return(ret);
 }
 
index db09bf7..7bb0a6f 100644 (file)
@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $DragonFly: src/lib/libthread_xu/thread/thr_mutex_protocol.c,v 1.3 2006/04/06 13:03:09 davidxu Exp $
+ * $DragonFly: src/lib/libthread_xu/thread/thr_mutex_protocol.c,v 1.4 2008/07/15 01:18:53 dillon Exp $
  */
 
 #include "namespace.h"
@@ -62,7 +62,7 @@ _pthread_mutexattr_setprotocol(pthread_mutexattr_t *mattr, int protocol)
                ret = EINVAL;
        else {
                (*mattr)->m_protocol = protocol;
-               (*mattr)->m_ceiling = THR_MAX_PRIORITY;
+               (*mattr)->m_ceiling = THR_MUTEX_CEIL_PRIORITY;
        }
        return(ret);
 }
index 8f59513..980e657 100644 (file)
@@ -32,7 +32,7 @@
  * Private thread definitions for the uthread kernel.
  *
  * $FreeBSD: src/lib/libpthread/thread/thr_private.h,v 1.120 2004/11/01 10:49:34 davidxu Exp $
- * $DragonFly: src/lib/libthread_xu/thread/thr_private.h,v 1.18 2008/04/14 20:12:41 dillon Exp $
+ * $DragonFly: src/lib/libthread_xu/thread/thr_private.h,v 1.19 2008/07/15 01:18:53 dillon Exp $
  */
 
 #ifndef _THR_PRIVATE_H
@@ -277,15 +277,8 @@ struct pthread_attr {
  * The approach taken is that, within each class, signal delivery
  * always has priority over thread execution.
  */
-#define THR_DEFAULT_PRIORITY                   15
-#define THR_MIN_PRIORITY                       0
-#define THR_MAX_PRIORITY                       31      /* 0x1F */
-#define THR_SIGNAL_PRIORITY                    32      /* 0x20 */
-#define THR_RT_PRIORITY                                64      /* 0x40 */
-#define THR_FIRST_PRIORITY                     THR_MIN_PRIORITY
-#define THR_LAST_PRIORITY      \
-       (THR_MAX_PRIORITY + THR_SIGNAL_PRIORITY + THR_RT_PRIORITY)
-#define THR_BASE_PRIORITY(prio)        ((prio) & THR_MAX_PRIORITY)
+#define THR_DEFAULT_PRIORITY           0
+#define THR_MUTEX_CEIL_PRIORITY                31      /* dummy */
 
 /*
  * Time slice period in microseconds.