Messages in this thread | | | Date | Fri, 12 Mar 1999 20:05:45 +0700 (JAVT) | From | "imel..." <> | Subject | need help w/ clone(2) |
| |
hi all,
i wrote a small program to use the clone(2) (not glibc's), and had a problem: the new thread was there but wasn't running could you take a look and see what's wrong with it please... i need this running or we'll have java for operating system class.
---
#include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <time.h> #include <sys/wait.h> #include <asm/unistd.h>
#include <linux/time.h> #include <asm/page.h> #include <linux/sched.h>
_syscall4(int, clone, void *, fn, void *, child_stack, int, flags, void *, arg) int test();
main() { int stack[1024]; struct timespec val = {0, 300000000};
if (clone((void *)test, (void *)&stack[1023], CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD, NULL) == -1) perror("clone"); wait4(0, NULL, 0, NULL); return 0; }
int test() { while (1) { nanosleep(&val, NULL); printf("child thread\n"); } return 0; }
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |