Need help to create a thread

C H Gopinath (gopich@cse.iitb.ernet.in)
Fri, 21 Nov 1997 00:32:19 +0530 (IST)


hi,
Thanks for your time.

I want to create a system call similar to pthread_create().

create_thread((void *)(*strtfn)(void *), void *arg ));

strtfn - function to be executed.
arg - arguments to the function.

I tried the following, but kernel_thread executes one function after
the other. I want overlapped execution of the functions.

How to do this??

#define __KERNEL_SYSCALLS__
#include <linux/module.h>

#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/locks.h>
#include <linux/posix_types.h>
#include <linux/types.h>
#include <linux/unistd.h>

#include <asm/system.h>
#include <asm/io.h>
#include <asm/segment.h>
#include <asm/unistd.h>

int count=5000;
static int start1(void *unused)
{
int i;
for (i=0;i<count;i++)
printk("hello I am first thread\n");
return 1;
}

static int start2(void *unused)
{
int i;
for (i=0;i<count;i++)
printk("hello I am second thread\n");
return 1;
}

asmlinkage int sys_create_thread(void)
{

kernel_thread(start1,NULL,0);
kernel_thread(start2,NULL,0);
return 1;
}

--
   Gopinath
   gopich@cse.iitb.ernet.in