tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

realtime functions in userland



Hi -
it seems that ~every other OS has the realtime support functions
either all present in librt, or in libc.
We have currently the new sched* things in librt, but
clock_gettime() etc in libc for historical reasons.

I've just tried to build cdrtools with realtime scheduling
support, and it checks for clock_gettime(), doesn't find
it in librt but in libc, and decides that librt should
not be used. This might be a bit radical from cdrtool's
side (and there are some more minor problems), but generally
this is an inconsistency on our side.

So we could move everything to libc, or provide entries
in librt. I'd prefer the latter for sanity.

Here is a patch which shows how this could be done. It is
a proof-of-concept for now, does only deal with
clock_gettime() -- which is actually sufficient for cdrtools.

Comments - is that the way to go?

The priority boost does actually work - ps(1) shows a priority
of 190 for that process:
1127  4381 17276   0  95  0  864   1788 wait    Is   ttyp5  0:00.25 -bash
   0 22467 28152   0  95  0  764   1040 pipe    S+   ttyp5  0:00.63 cdda2wav -B
   0 28152  2954   0 190  0  764   1540 xscmd   DL+  ttyp5  0:00.37 cdda2wav -B

best regards
Matthias





-------------------------------------------------------------------
-------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich

Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Dr. Sebastian M. Schmidt
-------------------------------------------------------------------
-------------------------------------------------------------------
#
# old_revision [e2368404df42820ff008a051a17bdf933c82a547]
#
# add_file "lib/libc/compat/sys/compat_clock_gettime.c"
#  content [572485a6b840a2ea03583a4492596d11bbd05b68]
# 
# add_file "lib/librt/clock_gettime.c"
#  content [572485a6b840a2ea03583a4492596d11bbd05b68]
# 
# patch "lib/libc/compat/sys/Makefile.inc"
#  from [260a5e8d54892b07d7b8b4fbb59cdae1c7a3be6a]
#    to [fac9a2f1fdba00fa66713f717efb3f3201beb1b2]
# 
# patch "lib/libc/include/namespace.h"
#  from [7f4ba8641f1b1895981971b75d4616688be44c16]
#    to [0f20aab3719ca25afd6f1d9b076b7435e1b79783]
# 
# patch "lib/libc/isc/ev_timers.c"
#  from [c37b9e61d0a82040cfe7b9277b9c420c9d506b42]
#    to [521b93f64575a7f4d5545a6751a2accc43dc7f8c]
# 
# patch "lib/libc/sys/Makefile.inc"
#  from [68006b3814ce0b66fc344ce3517194fb9bc496eb]
#    to [3c6ff8321d535db9c3bd034d0e5112496b382154]
# 
# patch "lib/libc/sys/clock_settime.2"
#  from [5e4f4008c58dd72dbc1b89146eb56bc0dd308e22]
#    to [e5ce9639c93c2a2649afabd5f476a935e4a40c47]
# 
# patch "lib/librt/Makefile"
#  from [fcfe85ca1c9d64938041dfd793a7e6a5c71d0f85]
#    to [c75ebc7811df47c35ef8ebdae37f46c6f7e38715]
#
============================================================
--- lib/libc/compat/sys/compat_clock_gettime.c  
572485a6b840a2ea03583a4492596d11bbd05b68
+++ lib/libc/compat/sys/compat_clock_gettime.c  
572485a6b840a2ea03583a4492596d11bbd05b68
@@ -0,0 +1,11 @@
+#include <sys/cdefs.h>
+#include <time.h>
+
+extern int __clock_gettime(clockid_t, struct timespec *);
+
+int
+clock_gettime(clockid_t c, struct timespec *t)
+{
+
+       return __clock_gettime(c, t);
+}
============================================================
--- lib/librt/clock_gettime.c   572485a6b840a2ea03583a4492596d11bbd05b68
+++ lib/librt/clock_gettime.c   572485a6b840a2ea03583a4492596d11bbd05b68
@@ -0,0 +1,11 @@
+#include <sys/cdefs.h>
+#include <time.h>
+
+extern int __clock_gettime(clockid_t, struct timespec *);
+
+int
+clock_gettime(clockid_t c, struct timespec *t)
+{
+
+       return __clock_gettime(c, t);
+}
============================================================
--- lib/libc/compat/sys/Makefile.inc    260a5e8d54892b07d7b8b4fbb59cdae1c7a3be6a
+++ lib/libc/compat/sys/Makefile.inc    fac9a2f1fdba00fa66713f717efb3f3201beb1b2
@@ -1,7 +1,8 @@
 #      $NetBSD: Makefile.inc,v 1.7 2007/07/14 15:53:04 dsl Exp $
 
 .PATH: ${COMPATDIR}/sys
-SRCS+= compat_getdents.c compat_getdirentries.c compat_msync.c \
+SRCS+= compat_clock_gettime.c \
+    compat_getdents.c compat_getdirentries.c compat_msync.c \
     compat_ntp_gettime.c \
     compat_semctl.c compat_sigaltstack.c compat_stat.c compat___stat13.c \
     compat_statfs.c compat_socket.c compat_getfh.c \
============================================================
--- lib/libc/include/namespace.h        7f4ba8641f1b1895981971b75d4616688be44c16
+++ lib/libc/include/namespace.h        0f20aab3719ca25afd6f1d9b076b7435e1b79783
@@ -43,6 +43,7 @@
 #define catclose       _catclose
 #define catgets                _catgets
 #define catopen                _catopen
+#define clock_gettime  __clock_gettime /* asm stub */
 #define daylight       _daylight
 #define err            _err
 #define errx           _errx
============================================================
--- lib/libc/isc/ev_timers.c    c37b9e61d0a82040cfe7b9277b9c420c9d506b42
+++ lib/libc/isc/ev_timers.c    521b93f64575a7f4d5545a6751a2accc43dc7f8c
@@ -30,6 +30,8 @@ __RCSID("$NetBSD: ev_timers.c,v 1.5 2007
 #endif
 #endif
 
+#include "namespace.h"
+
 /* Import. */
 
 #include "port_before.h"
============================================================
--- lib/libc/sys/Makefile.inc   68006b3814ce0b66fc344ce3517194fb9bc496eb
+++ lib/libc/sys/Makefile.inc   3c6ff8321d535db9c3bd034d0e5112496b382154
@@ -32,6 +32,8 @@ GLUE+=        adjtime.c clock_settime.c ftrunca
        pwritev.c settimeofday.c \
        truncate.c
 
+ASM_GLUE+= __clock_gettime.S
+
 # 'glue' files might .c or .S depending on the architecture
 .for glue in ${GLUE}
 .if exists(${glue:.c=.S})
@@ -57,7 +59,6 @@ ASM=  access.S acct.S \
 ASM=   access.S acct.S \
        bind.S \
        chdir.S chflags.S chmod.S chown.S chroot.S clock_getres.S \
-               clock_gettime.S \
        dup.S dup2.S  \
        extattrctl.S \
                extattr_delete_fd.S extattr_delete_file.S \
============================================================
--- lib/libc/sys/clock_settime.2        5e4f4008c58dd72dbc1b89146eb56bc0dd308e22
+++ lib/libc/sys/clock_settime.2        e5ce9639c93c2a2649afabd5f476a935e4a40c47
@@ -34,7 +34,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 11, 1999
+.Dd January 16, 2008
 .Dt CLOCK_SETTIME 2
 .Os
 .Sh NAME
@@ -43,7 +43,7 @@
 .Nm clock_getres
 .Nd clock and timer functions
 .Sh LIBRARY
-.Lb libc
+.Lb librt
 .Sh SYNOPSIS
 .In time.h
 .Ft int
============================================================
--- lib/librt/Makefile  fcfe85ca1c9d64938041dfd793a7e6a5c71d0f85
+++ lib/librt/Makefile  c75ebc7811df47c35ef8ebdae37f46c6f7e38715
@@ -6,6 +6,7 @@ SRCS+=  sched.c
 LIB=   rt
 SRCS=  sem.c
 SRCS+= sched.c
+SRCS+= clock_gettime.c
 
 MAN+=  aio_cancel.3 aio_error.3 aio_fsync.3 aio_read.3 aio_return.3 \
        aio_suspend.3 aio_write.3 lio_listio.3 \


Home | Main Index | Thread Index | Old Index