diff mbox series

[v1,1/2] linux: Implement sched_yield in C

Message ID 20230607194643.2081329-1-goldstein.w.n@gmail.com
State New
Headers show
Series [v1,1/2] linux: Implement sched_yield in C | expand

Commit Message

Noah Goldstein June 7, 2023, 7:46 p.m. UTC
This is in preperation for a minor optimization before expected
context switches.
---
 sysdeps/unix/sysv/linux/sched_yield.c | 27 +++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/syscalls.list |  1 -
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/unix/sysv/linux/sched_yield.c

Comments

H.J. Lu June 7, 2023, 8:43 p.m. UTC | #1
On Wed, Jun 7, 2023 at 12:46 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> This is in preperation for a minor optimization before expected
> context switches.
> ---
>  sysdeps/unix/sysv/linux/sched_yield.c | 27 +++++++++++++++++++++++++++
>  sysdeps/unix/sysv/linux/syscalls.list |  1 -
>  2 files changed, 27 insertions(+), 1 deletion(-)
>  create mode 100644 sysdeps/unix/sysv/linux/sched_yield.c
>
> diff --git a/sysdeps/unix/sysv/linux/sched_yield.c b/sysdeps/unix/sysv/linux/sched_yield.c
> new file mode 100644
> index 0000000000..154bf725b0
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/sched_yield.c
> @@ -0,0 +1,27 @@
> +/* Yield current process.  Linux specific syscall.
> +   Copyright (C) 2023 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sysdep.h>
> +
> +int
> +__sched_yield (void)
> +{
> +    return INLINE_SYSCALL_CALL (sched_yield);
> +}
> +libc_hidden_def (__sched_yield);
> +weak_alias (__sched_yield, sched_yield)
> diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
> index 73e941ef89..5f571df937 100644
> --- a/sysdeps/unix/sysv/linux/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/syscalls.list
> @@ -59,7 +59,6 @@ sched_primax  -       sched_get_priority_max  i:i     __sched_get_priority_max        sched_get_pri
>  sched_primin   -       sched_get_priority_min  i:i     __sched_get_priority_min        sched_get_priority_min
>  sched_setp     -       sched_setparam  i:ip    __sched_setparam        sched_setparam
>  sched_sets     -       sched_setscheduler      i:iip   __sched_setscheduler    sched_setscheduler
> -sched_yield    -       sched_yield     i:      __sched_yield   sched_yield
>  setfsgid       EXTRA   setfsgid        i:i     setfsgid
>  setfsuid       EXTRA   setfsuid        i:i     setfsuid
>  setpgid                -       setpgid         i:ii    __setpgid       setpgid
> --
> 2.34.1


Is this really needed?   We can add x86-64 specific sched_yield.c.
Noah Goldstein June 8, 2023, 9:01 a.m. UTC | #2
On Wed, Jun 7, 2023 at 3:43 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Wed, Jun 7, 2023 at 12:46 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > This is in preperation for a minor optimization before expected
> > context switches.
> > ---
> >  sysdeps/unix/sysv/linux/sched_yield.c | 27 +++++++++++++++++++++++++++
> >  sysdeps/unix/sysv/linux/syscalls.list |  1 -
> >  2 files changed, 27 insertions(+), 1 deletion(-)
> >  create mode 100644 sysdeps/unix/sysv/linux/sched_yield.c
> >
> > diff --git a/sysdeps/unix/sysv/linux/sched_yield.c b/sysdeps/unix/sysv/linux/sched_yield.c
> > new file mode 100644
> > index 0000000000..154bf725b0
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/sched_yield.c
> > @@ -0,0 +1,27 @@
> > +/* Yield current process.  Linux specific syscall.
> > +   Copyright (C) 2023 Free Software Foundation, Inc.
> > +   This file is part of the GNU C Library.
> > +
> > +   The GNU C Library is free software; you can redistribute it and/or
> > +   modify it under the terms of the GNU Lesser General Public
> > +   License as published by the Free Software Foundation; either
> > +   version 2.1 of the License, or (at your option) any later version.
> > +
> > +   The GNU C Library is distributed in the hope that it will be useful,
> > +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > +   Lesser General Public License for more details.
> > +
> > +   You should have received a copy of the GNU Lesser General Public
> > +   License along with the GNU C Library; if not, see
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <sysdep.h>
> > +
> > +int
> > +__sched_yield (void)
> > +{
> > +    return INLINE_SYSCALL_CALL (sched_yield);
> > +}
> > +libc_hidden_def (__sched_yield);
> > +weak_alias (__sched_yield, sched_yield)
> > diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
> > index 73e941ef89..5f571df937 100644
> > --- a/sysdeps/unix/sysv/linux/syscalls.list
> > +++ b/sysdeps/unix/sysv/linux/syscalls.list
> > @@ -59,7 +59,6 @@ sched_primax  -       sched_get_priority_max  i:i     __sched_get_priority_max        sched_get_pri
> >  sched_primin   -       sched_get_priority_min  i:i     __sched_get_priority_min        sched_get_priority_min
> >  sched_setp     -       sched_setparam  i:ip    __sched_setparam        sched_setparam
> >  sched_sets     -       sched_setscheduler      i:iip   __sched_setscheduler    sched_setscheduler
> > -sched_yield    -       sched_yield     i:      __sched_yield   sched_yield
> >  setfsgid       EXTRA   setfsgid        i:i     setfsgid
> >  setfsuid       EXTRA   setfsuid        i:i     setfsuid
> >  setpgid                -       setpgid         i:ii    __setpgid       setpgid
> > --
> > 2.34.1
>
>
> Is this really needed?   We can add x86-64 specific sched_yield.c.
>
>
> --
> H.J.
abandoning this.
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/sched_yield.c b/sysdeps/unix/sysv/linux/sched_yield.c
new file mode 100644
index 0000000000..154bf725b0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sched_yield.c
@@ -0,0 +1,27 @@ 
+/* Yield current process.  Linux specific syscall.
+   Copyright (C) 2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+int
+__sched_yield (void)
+{
+    return INLINE_SYSCALL_CALL (sched_yield);
+}
+libc_hidden_def (__sched_yield);
+weak_alias (__sched_yield, sched_yield)
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 73e941ef89..5f571df937 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -59,7 +59,6 @@  sched_primax	-	sched_get_priority_max	i:i	__sched_get_priority_max	sched_get_pri
 sched_primin	-	sched_get_priority_min	i:i	__sched_get_priority_min	sched_get_priority_min
 sched_setp	-	sched_setparam	i:ip	__sched_setparam	sched_setparam
 sched_sets	-	sched_setscheduler	i:iip	__sched_setscheduler	sched_setscheduler
-sched_yield	-	sched_yield	i:	__sched_yield	sched_yield
 setfsgid	EXTRA	setfsgid	i:i	setfsgid
 setfsuid	EXTRA	setfsuid	i:i	setfsuid
 setpgid		-	setpgid		i:ii	__setpgid	setpgid