Issue with clock_nanosleep(), TIMER_ABSTIME andCONFIG_CC_OPTIMIZE_FOR_SIZE not set
From: M. Koehrer
Date: Thu Apr 09 2009 - 04:22:24 EST
Hi all!
I am using kernel 2.6.29.1 from kernel.org on a Debian 5.0 (Lenny) system (Intel Core2Quad).
GCC is 4.3.2
I have not set CONFIG_CC_OPT_SIZE.
When I use clock_nanosleep with TIMER_ABSTIME with gdb and stop the execution by CTRL-C,
I cannot continue the execution of my program when it interrupted the clock_nanosleep call.
When I set the kernel config parameter CONFIG_CC_OPT_SIZE everything is fine.
There seems to be an optimization issue that is related to the clock_nanosleep system call.
Some more remarks:
When I use relative times (mode set to 0) everything works fine in both cases.
CONFIG_TICK_ONESHOT=y
CONFIG_HIGH_RES_TIMERS=y
Here is my tiny test program that demonstrates the behaviour:
Let it run in gdb, interrupt it (CTRL-C) and try to continue "c".
***************** BEGIN ************************
#define _GNU_SOURCE
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <linux/unistd.h>
const clockid_t CLOCK_TO_USE=CLOCK_MONOTONIC;
static int clock_nanosleep2(clockid_t clock_id, int flags, const struct timespec *req,
struct timespec *rem)
{
return syscall(__NR_clock_nanosleep, clock_id, flags, req, rem);
}
int main(void)
{
int i;
struct timespec ts;
clock_gettime(CLOCK_TO_USE, &ts);
for (i=0; i<=1000; i++)
{
ts.tv_sec++;
clock_nanosleep2(CLOCK_TO_USE, TIMER_ABSTIME, &ts, NULL);
// clock_nanosleep(CLOCK_TO_USE, TIMER_ABSTIME, &ts, NULL);
printf("%i\n",i);
}
return 0;
}
/* Build with
gcc test_clock_nanosleep.c -g -Wall -lrt
*/
**************** END *******************
Thanks for all feedback on that issue
Regards
Mathias
--
Mathias Koehrer
mathias_koehrer@xxxxxxxx
Zerreißen Sie die Netze der Phisher, Hacker und Betrüger!
Ihre Internet-Sicherheits-Seiten auf Arcor.de bieten alle Infos und Hilfsmittel, die Sie zum sicheren Surfen brauchen! Play it safe!
http://www.arcor.de/footer-sicherheit/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/