mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Issue with clock_nanosleep(), TIMER_ABSTIME and CONFIG_CC_OPTIMIZE_FOR_SIZE not set
@ 2009-04-09  8:22 M. Koehrer
  0 siblings, 0 replies; only message in thread
From: M. Koehrer @ 2009-04-09  8:22 UTC (permalink / raw)
  To: linux-kernel

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@arcor.de


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/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-04-09  8:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-09  8:22 Issue with clock_nanosleep(), TIMER_ABSTIME and CONFIG_CC_OPTIMIZE_FOR_SIZE not set M. Koehrer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome