From 7ec291780c8dbe2f009415157e77f9d2934f80de Mon Sep 17 00:00:00 2001 From: joq Date: Sat, 4 Dec 2004 03:02:26 +0000 Subject: [PATCH] [0.99.21] add CHECK_PREEMPTION() macro to libjack git-svn-id: svn+ssh://jackaudio.org/trunk/jack@818 0c269be4-1314-0410-8aa9-9f06e86f4224 --- configure.ac | 13 ++++++++++++- jack/internal.h | 14 ++++++++++++++ libjack/client.c | 6 ++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6852ecf..66d3d67 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ dnl changes are made dnl --- JACK_MAJOR_VERSION=0 JACK_MINOR_VERSION=99 -JACK_MICRO_VERSION=20 +JACK_MICRO_VERSION=21 dnl --- dnl HOWTO: updating the jack protocol version @@ -318,6 +318,17 @@ AC_ARG_ENABLE(timestamps, ] ) +AC_ARG_ENABLE(preemption-check, + AC_HELP_STRING([--enable-preemption-check], + [check for inappropriate realtime preemption]), + [ + if test x$enable_preemption_check != xno ; then + echo checking for realtime preemption bugs + AC_DEFINE(DO_PREEMPTION_CHECKING,, + [check realtime preemption]) + fi + ]) + USE_CAPABILITIES=false AC_ARG_ENABLE(capabilities, diff --git a/jack/internal.h b/jack/internal.h index d53c962..285debc 100644 --- a/jack/internal.h +++ b/jack/internal.h @@ -60,6 +60,20 @@ extern void jack_error (const char *fmt, ...); #endif #endif +/* Enable preemption checking for Linux Realtime Preemption kernels. + * + * This checks if any RT-safe code section does anything to cause + * possible CPU preemption. Examples are sleep() or other system + * calls that block. If a problem is detected, the kernel writes a + * syslog entry, and sends SIGUSR2 to the client. + */ +#ifdef DO_PREEMPTION_CHECKING +#define CHECK_PREEMPTION(engine, onoff) \ + if ((engine)->real_time) gettimeofday (1, (onoff)) +#else +#define CHECK_PREEMPTION(engine, onoff) +#endif + #ifndef FALSE #define FALSE (0) #endif diff --git a/libjack/client.c b/libjack/client.c index 0d07ec5..f2f9334 100644 --- a/libjack/client.c +++ b/libjack/client.c @@ -1235,6 +1235,9 @@ jack_client_thread (void *arg) control->state = Running; + /* begin preemption checking */ + CHECK_PREEMPTION (client->engine, TRUE); + if (control->sync_cb) jack_call_sync_client (client); @@ -1251,6 +1254,9 @@ jack_client_thread (void *arg) if (control->timebase_cb) jack_call_timebase_master (client); + /* end preemption checking */ + CHECK_PREEMPTION (client->engine, FALSE); + control->finished_at = jack_get_microseconds(); #ifdef WITH_TIMESTAMPS