[PATCH] cpukit: Merge FreeBSD values for the priorities

Joel Sherrill joel at rtems.org
Wed Dec 23 22:20:17 UTC 2020


This looks ok if these priorities are mapped to Classic or Score. POSIX
thread priorities run opposite.

On Wed, Dec 23, 2020, 2:36 PM <chrisj at rtems.org> wrote:

> From: Chris Johns <chrisj at rtems.org>
>
> It seems we need valid values or assumptions in the FreeBSD about
> these values breaks some of the code.
>
> Closes #4207
> ---
>  cpukit/include/sys/priority.h | 102 ++++++++++++++++++++++++++++------
>  1 file changed, 85 insertions(+), 17 deletions(-)
>
> diff --git a/cpukit/include/sys/priority.h b/cpukit/include/sys/priority.h
> index 025de6290c..855edb63c2 100644
> --- a/cpukit/include/sys/priority.h
> +++ b/cpukit/include/sys/priority.h
> @@ -1,5 +1,7 @@
> -/*
> - * Copyright (c) 2015 embedded brains GmbH
> +/*-
> + * SPDX-License-Identifier: BSD-4-Clause
> + *
> + * Copyright (c) 1994, Henrik Vestergaard Draboel
>   * All rights reserved.
>   *
>   * Redistribution and use in source and binary forms, with or without
> @@ -10,6 +12,11 @@
>   * 2. Redistributions in binary form must reproduce the above copyright
>   *    notice, this list of conditions and the following disclaimer in the
>   *    documentation and/or other materials provided with the distribution.
> + * 3. All advertising materials mentioning features or use of this
> software
> + *    must display the following acknowledgement:
> + *      This product includes software developed by Henrik Vestergaard
> Draboel.
> + * 4. The name of the author may not be used to endorse or promote
> products
> + *    derived from this software without specific prior written
> permission.
>   *
>   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
>   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> @@ -22,23 +29,84 @@
>   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
> WAY
>   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>   * SUCH DAMAGE.
> + *
> + * $FreeBSD$
>   */
>
>  #ifndef _SYS_PRIORITY_H_
> -#define        _SYS_PRIORITY_H_
> -
> -/* Dummy values to make the libbsd happy */
> -#define        PRI_MAX_ITHD            0
> -#define        PI_NET                  0
> -#define        PI_DISK                 0
> -#define        PI_SOFT                 0
> -#define        PI_SWI(x)               0
> -#define        PRI_MIN_KERN            0
> -#define        PVM                     0
> -#define        PRIBIO                  0
> -#define        PZERO                   0
> -#define        PSOCK                   0
> -#define        PWAIT                   0
> -#define        PPAUSE                  0
> +#define _SYS_PRIORITY_H_
> +
> +/*
> + * Process priority specifications.
> + */
> +
> +/*
> + * Priority classes.
> + */
> +
> +#define PRI_ITHD                1       /* Interrupt thread. */
> +#define PRI_REALTIME            2       /* Real time process. */
> +#define PRI_TIMESHARE           3       /* Time sharing process. */
> +#define PRI_IDLE                4       /* Idle process. */
> +
> +/*
> + * Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ)
> + * are insignificant.  Ranges are as follows:
> + *
> + * Interrupt threads:           0 - 47
> + * Realtime user threads:       48 - 79
> + * Top half kernel threads:     80 - 119
> + * Time sharing user threads:   120 - 223
> + * Idle user threads:           224 - 255
> + *
> + * XXX If/When the specific interrupt thread and top half thread ranges
> + * disappear, a larger range can be used for user processes.
> + */
> +
> +#define PRI_MIN                 (0)             /* Highest priority. */
> +#define PRI_MAX                 (255)           /* Lowest priority. */
> +
> +#define PRI_MIN_ITHD            (PRI_MIN)
> +#define PRI_MAX_ITHD            (PRI_MIN_REALTIME - 1)
> +
> +#define PI_REALTIME             (PRI_MIN_ITHD + 0)
> +#define PI_AV                   (PRI_MIN_ITHD + 4)
> +#define PI_NET                  (PRI_MIN_ITHD + 8)
> +#define PI_DISK                 (PRI_MIN_ITHD + 12)
> +#define PI_TTY                  (PRI_MIN_ITHD + 16)
> +#define PI_DULL                 (PRI_MIN_ITHD + 20)
> +#define PI_SOFT                 (PRI_MIN_ITHD + 24)
> +#define PI_SWI(x)               (PI_SOFT + (x) * RQ_PPQ)
> +
> +#define PRI_MIN_REALTIME        (48)
> +#define PRI_MAX_REALTIME        (PRI_MIN_KERN - 1)
> +
> +#define PRI_MIN_KERN            (80)
> +#define PRI_MAX_KERN            (PRI_MIN_TIMESHARE - 1)
> +
> +#define PSWP                    (PRI_MIN_KERN + 0)
> +#define PVM                     (PRI_MIN_KERN + 4)
> +#define PINOD                   (PRI_MIN_KERN + 8)
> +#define PRIBIO                  (PRI_MIN_KERN + 12)
> +#define PVFS                    (PRI_MIN_KERN + 16)
> +#define PZERO                   (PRI_MIN_KERN + 20)
> +#define PSOCK                   (PRI_MIN_KERN + 24)
> +#define PWAIT                   (PRI_MIN_KERN + 28)
> +#define PLOCK                   (PRI_MIN_KERN + 32)
> +#define PPAUSE                  (PRI_MIN_KERN + 36)
> +
> +#define PRI_MIN_TIMESHARE       (120)
> +#define PRI_MAX_TIMESHARE       (PRI_MIN_IDLE - 1)
> +
> +#define PUSER                   (PRI_MIN_TIMESHARE)
> +
> +#define PRI_MIN_IDLE            (224)
> +#define PRI_MAX_IDLE            (PRI_MAX)
> +
> +#ifdef _KERNEL
> +/* Other arguments for kern_yield(9). */
> +#define PRI_USER        -2      /* Change to current user priority. */
> +#define PRI_UNCHANGED   -1      /* Do not change priority. */
> +#endif
>
>  #endif /* !_SYS_PRIORITY_H_ */
> --
> 2.24.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20201223/66708898/attachment.html>


More information about the devel mailing list