This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/1256] Thread/process-specific CPU-time clock not implemented correctly?


------- Additional Comments From myself at rojer dot pp dot ru  2005-08-28 18:36 -------
(In reply to comment #1)
> What kernel?  How was the glibc compiled?  strace of the running process.

[root@xxx rojer]# uname -a
Linux xxx.yyy.ru 2.6.9-11.ELhugemem #1 SMP Fri May 20 18:34:54 EDT 2005 i686
i686 i386 GNU/Linux
[root@xxx rojer]# rpm -qa | grep glibc
glibc-kernheaders-2.4-9.1.87
glibc-common-2.3.4-2.9
glibc-headers-2.3.4-2.9
glibc-2.3.4-2.9
glibc-devel-2.3.4-2.9
[root@xxx rojer]# cat sleepy.c
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>
#define MY_CLOCK_ID CLOCK_THREAD_CPUTIME_ID
//#define MY_CLOCK_ID CLOCK_MONOTONIC
//#define MY_CLOCK_ID CLOCK_PROCESS_CPUTIME_ID

void *sleepy(void *dummy) {

        struct timespec start, end;
        int err;

        printf("sleepy: started\n");

        err = clock_gettime(MY_CLOCK_ID, &start);
        printf("sleepy: err=%d, errno=%d\n", err, errno);

        for (;;) {
                sleep(3);
                clock_gettime(MY_CLOCK_ID, &end);
                printf("sleepy: %d, %d\n", end.tv_sec, end.tv_nsec);
        }
}

int main(int argc, char **argv)
{
        pthread_t t1;
        pthread_create(&t1, NULL, sleepy, NULL);
        pause();
}
[root@xxx rojer]# strace -f ./sleepy
<snip>
clone(Process 28249 attached
child_stack=0xf6ff54c4,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
parent_tidptr=0xf6ff5bf8, {entry_number:6, base_addr:0xf6ff5bb0, limit:1048575,
seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0,
useable:1}, child_tidptr=0xf6ff5bf8) = 28249
[pid 28248] pause( <unfinished ...>
[pid 28249] fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
[pid 28249] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0xf65f4000
[pid 28249] write(1, "sleepy: started\n", 16sleepy: started
) = 16
[pid 28249] open("/proc/cpuinfo", O_RDONLY) = 3
[pid 28249] read(3, "processor\t: 0\nvendor_id\t: Genuin"..., 4096) = 934
[pid 28249] close(3)                    = 0
[pid 28249] write(1, "sleepy: err=0, errno=0\n", 23sleepy: err=0, errno=0
) = 23
[pid 28249] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
[pid 28249] rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
[pid 28249] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 28249] nanosleep({3, 0}, {3, 0})   = 0
[pid 28249] write(1, "sleepy: 3, 11683829\n", 20sleepy: 3, 11683829
) = 20
[pid 28249] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
[pid 28249] rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
[pid 28249] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 28249] nanosleep({3, 0}, {3, 0})   = 0
[pid 28249] write(1, "sleepy: 6, 12452432\n", 20sleepy: 6, 12452432
) = 20
[pid 28249] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
[pid 28249] rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
[pid 28249] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 28249] nanosleep({3, 0}, {3, 0})   = 0
[pid 28249] write(1, "sleepy: 9, 41031996\n", 20sleepy: 9, 41031996
) = 20
[pid 28249] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
[pid 28249] rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
[pid 28249] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 28249] nanosleep({3, 0}, {3, 0})   = 0
[pid 28249] write(1, "sleepy: 12, 203684476\n", 22sleepy: 12, 203684476
) = 22
[pid 28249] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
[pid 28249] rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
[pid 28249] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 28249] nanosleep({3, 0},  <unfinished ...>
Process 28249 detached
[root@xxx rojer]# 

-- 


http://sources.redhat.com/bugzilla/show_bug.cgi?id=1256

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]