Thread 3 (Thread 0x7ffff73fe640 (LWP 2782) "sem"): #0 __sleep (seconds=2) at ../sysdeps/posix/sleep.c:34 #1 0x00005555555552d9 in dequeue (arg=0x7fffffffe300) at test_sem.c:31 #2 0x00007ffff7c94ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442 #3 0x00007ffff7d26a40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Thread 2 (Thread 0x7ffff7bff640 (LWP 2781) "sem"): #0 enqueue (arg=0x7fffffffe300) at test_sem.c:48 #1 0x00007ffff7c94ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442 #2 0x00007ffff7d26a40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Thread 1 (Thread 0x7ffff7faa740 (LWP 2778) "sem"): #0 clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:62 #1 0x00007ffff7d26a91 in __GI___clone_internal (cl_args=cl_args@entry=0x7fffffffe0b0, func=func@entry=0x7ffff7c947d0 <start_thread>, arg=arg@entry=0x7ffff73fe640) at ../sysdeps/unix/sysv/linux/clone-internal.c:54 #2 0x00007ffff7c946d9 in create_thread (pd=pd@entry=0x7ffff73fe640, attr=attr@entry=0x7fffffffe1d0, stopped_start=stopped_start@entry=0x7fffffffe1ce, stackaddr=stackaddr@entry=0x7ffff6bfe000, stacksize=8388352, thread_ran=thread_ran@entry=0x7fffffffe1cf) at ./nptl/pthread_create.c:295 #3 0x00007ffff7c95200 in __pthread_create_2_1 (newthread=<optimized out>, attr=<optimized out>, start_routine=<optimized out>, arg=<optimized out>) at ./nptl/pthread_create.c:828 #4 0x00005555555554ad in main () at test_sem.c:77 (gdb)
(gdb) show scheduler-locking Mode for locking scheduler during execution is "replay". (gdb) set schedule-l Display all 150 possibilities? (y or n) (gdb) set schedule-lock lock lock_fd locked_map_ptr locked_vfxprintf lockf lockf64 (gdb) set schedule-lock lock lock_fd locked_map_ptr locked_vfxprintf lockf lockf64 (gdb) set schedule-lock Display all 200 possibilities? (y or n) (gdb) set scheduler-locking on (gdb) show scheduler-locking Mode for locking scheduler during execution is "on". (gdb)
(gdb) set non-stop on (gdb) show non-stop Controlling the inferior in non-stop mode is on. (gdb) b enqueue Breakpoint 1 at 0x138d: file test_sem.c, line 48. (gdb) r Starting program: /media/VM_SHARE/code/blog_code/condition/sem [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff7bff640 (LWP 2930)] [New Thread 0x7ffff73fe640 (LWP 2931)]
Thread 2 "sem" hit Breakpoint 1, enqueue (arg=0x7fffffffe300) at test_sem.c:48 48 thrd_args_t *thrd_args = (thrd_args_t *)arg; (gdb) set print thread-events off (gdb) info threads Id Target Id Frame * 1 Thread 0x7ffff7faa740 (LWP 2927) "sem" (running) 2 Thread 0x7ffff7bff640 (LWP 2930) "sem" enqueue (arg=0x7fffffffe300) at test_sem.c:48 3 Thread 0x7ffff73fe640 (LWP 2931) "sem" (running) (gdb) (gdb) interrupt -a (gdb) Thread 3 "sem" stopped. 0x00007ffff7ce57f8 in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=req@entry=0x7ffff73fddf0, rem=rem@entry=0x7ffff73fddf0) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78 78 ../sysdeps/unix/sysv/linux/clock_nanosleep.c: 没有那个文件或目录.
Thread 1 "sem" stopped. __futex_abstimed_wait_common64 (private=128, cancel=true, abstime=0x0, op=265, expected=2930, futex_word=0x7ffff7bff910) at ./nptl/futex-internal.c:57 57 ./nptl/futex-internal.c: 没有那个文件或目录. info threads Id Target Id Frame * 1 Thread 0x7ffff7faa740 (LWP 2927) "sem" __futex_abstimed_wait_common64 (private=128, cancel=true, abstime=0x0, op=265, expected=2930, futex_word=0x7ffff7bff910) at ./nptl/futex-internal.c:57 2 Thread 0x7ffff7bff640 (LWP 2930) "sem" enqueue (arg=0x7fffffffe300) at test_sem.c:48 3 Thread 0x7ffff73fe640 (LWP 2931) "sem" 0x00007ffff7ce57f8 in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=req@entry=0x7ffff73fddf0, rem=rem@entry=0x7ffff73fddf0) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78 (gdb)
(gdb) c& Continuing. (gdb) info threads Id Target Id Frame * 1 Thread 0x7ffff7faa740 (LWP 2927) "sem" (running) 2 Thread 0x7ffff7bff640 (LWP 2930) "sem" enqueue (arg=0x7fffffffe300) at test_sem.c:48 3 Thread 0x7ffff73fe640 (LWP 2931) "sem" 0x00007ffff7ce57f8 in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=req@entry=0x7ffff73fddf0, rem=rem@entry=0x7ffff73fddf0) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78 (gdb) thread apply all bt
Thread 3 (Thread 0x7ffff73fe640 (LWP 2931) "sem"): #0 0x00007ffff7ce57f8 in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=req@entry=0x7ffff73fddf0, rem=rem@entry=0x7ffff73fddf0) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78 #1 0x00007ffff7cea677 in __GI___nanosleep (req=req@entry=0x7ffff73fddf0, rem=rem@entry=0x7ffff73fddf0) at ../sysdeps/unix/sysv/linux/nanosleep.c:25 #2 0x00007ffff7cea5ae in __sleep (seconds=0) at ../sysdeps/posix/sleep.c:55 #3 0x00005555555552d9 in dequeue (arg=0x7fffffffe300) at test_sem.c:31 #4 0x00007ffff7c94ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442 #5 0x00007ffff7d26a40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Thread 2 (Thread 0x7ffff7bff640 (LWP 2930) "sem"): #0 __sleep (seconds=1) at ../sysdeps/posix/sleep.c:34 #1 0x00005555555553b5 in enqueue (arg=0x7fffffffe300) at test_sem.c:52 #2 0x00007ffff7c94ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442 #3 0x00007ffff7d26a40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81