[Glibc-bsd-commits] r4603 - trunk/glibc-ports/fbtl-misc

Petr Salinger ps-guest at alioth.debian.org
Mon Jul 8 12:47:15 UTC 2013


Author: ps-guest
Date: 2013-06-25 06:33:57 +0000 (Tue, 25 Jun 2013)
New Revision: 4603

Added:
   trunk/glibc-ports/fbtl-misc/test-fork-thread.c
Log:
helper for mini-test of pthread


Added: trunk/glibc-ports/fbtl-misc/test-fork-thread.c
===================================================================
--- trunk/glibc-ports/fbtl-misc/test-fork-thread.c	                        (rev 0)
+++ trunk/glibc-ports/fbtl-misc/test-fork-thread.c	2013-06-25 06:33:57 UTC (rev 4603)
@@ -0,0 +1,43 @@
+#include <pthread.h>
+#include <sys/syscall.h>
+#include <stdio.h>
+  
+static inline long __thr_self()
+{ 
+  long ktid;
+  syscall(SYS_thr_self, &ktid);
+  return  ktid;
+};
+
+static inline int sys_getpid()
+{
+  return syscall(SYS_getpid);
+}
+
+void *doit(void*p)
+{
+int i;
+i = getpid();
+printf("%s: doit a %d %d %ld\n", p, i, sys_getpid(), __thr_self());
+sleep(2);
+i = getpid();
+printf("%s: doit b %d %d %ld\n", p, i, sys_getpid(),__thr_self());
+}
+
+int main()
+{
+int i;
+pthread_t pt;
+doit("begin");
+printf("going to fork a\n");
+i = fork();
+printf("ahoj c %d %d %ld\n", i, sys_getpid(),__thr_self());
+i = pthread_create(&pt, NULL, doit, "thread");
+printf("ahoj create %d %d %ld\n", i, sys_getpid(),__thr_self());
+sleep(1);
+printf("going to fork b\n");
+i = fork();
+printf("ahoj d %d %d %ld\n", i, sys_getpid(),__thr_self());
+doit("end");
+return 5 ;
+}
\ No newline at end of file




More information about the Glibc-bsd-commits mailing list