On 2016-03-22 at 12:10 Dan Cross <[email protected]> wrote:
> Added a 'sched_getcpu()' routine that returns the
> current pcore ID, as an analog to the routine of
> the same name in Linux. Rebuild your toolchain.
>
> Signed-off-by: Dan Cross <[email protected]>
> ---
> .../glibc-2.19-akaros/sysdeps/akaros/Makefile | 5 +++++
> .../sysdeps/akaros/sched_getcpu.c | 24
> ++++++++++++++++++++++ 2 files changed, 29 insertions(+)
> create mode 100644
> tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/sched_getcpu.c
>
> diff --git
> a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/Makefile
> b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/Makefile
> index fa44dc5..8dd52b0 100644 ---
> a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/Makefile
> +++
> b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/Makefile
> @@ -42,6 +42,11 @@ sysdep_routines += convS2M endif sysdep_headers +=
> fcall.h +# Scheduling related routines.
> +ifeq ($(subdir),stdlib)
> +sysdep_routines += sched_getcpu
> +endif
> +
I haven't tried building this yet, but have you been able to link to
sched_getcpu? Usually you need to add it to Versions too. Linux does:
glibc-2.19/sysdeps/unix/sysv/linux/Versions: epoll_pwait;
sync_file_range; sched_getcpu;
Basically, without something in Versions, glibc can use it internally
but external programs can't link against it.
> a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/sched_getcpu.c
> @@ -0,0 +1,24 @@ +/* Copyright (C) 1991, 1995, 1996, 1997 Free
> Software Foundation, Inc.
> + This file is part of the GNU C Library.
Minor thing, but since you wrote this, you don't need to use the FSF
CR header. I've been using:
/* Copyright (c) 2016 Google Inc.
> +#include <ros/procinfo.h>
> +
> +int sched_getcpu(void)
> +{
> + return __procinfo.vcoremap[__get_vcoreid()].pcoreid;
> +}
Try using vcore_id() instead of __get_vcoreid(). #include
<parlib/vcore.h> for it. That will use TLS instead of a syscall to get
the vcoreid.
Barret
--
You received this message because you are subscribed to the Google Groups
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.