lkml.org 
[lkml]   [1999]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectneed 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/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.031 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site