[Beowulf] Kernel_thread problem

Zhang Hui spacetiller at 163.com
Tue Nov 1 08:46:09 EST 2005


Hello,all
	
	I have forked two thread in kernel state with the function kernel_thread:
	kernel_thread(myfunc1,NULL,0);
	kernel_thread(myfunc2,NULL,0);
	But i find it's hard to stop them with the function following:

	int stop_myfunc1(void)
{
	DECLARE_WAITQUEUE(wait, current);

	if (!myfunc1_pid)
		return -ESRCH;

	IP_VS_INFO("stopping myfunc1 thread %d ...\n", myfunc1_pid);

	__set_current_state(TASK_UNINTERRUPTIBLE);
	add_wait_queue(&stop_myfunc1_wait, &wait); //stop_myfunc1_wait declared before
	wake_up(&sync_wait);
	schedule();
	__set_current_state(TASK_RUNNING);
	remove_wait_queue(&stop_myfunc1_wait, &wait);

	/* it is probably not correct here. we need use sys_wait4, but need
	to patch the kernel to export sys_wait4, check it later...
	sys_wait4(myfunc1_pid, NULL, __WCLONE, NULL); */

	waitpid(myfunc1_pid, NULL, __WCLONE);

	return 0;
}
    int stop_myfunc2(void) { /* the same with above */ }
	
	What's the problem?
 				

        Zhang Hui
        spacetiller at 163.com
          2005-11-01

_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf



More information about the Beowulf mailing list