public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Qn: kernel_thread()
@ 2002-02-02 17:16 Alpha Beta
  2002-02-02 22:09 ` Mark Zealey
  0 siblings, 1 reply; 2+ messages in thread
From: Alpha Beta @ 2002-02-02 17:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: abbashake007

In the code of 
int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
in arch/i386/kernel/process.c

as can be seen in the code here, a system call is made by trigerring the 0x80 interrupt.
this function kernel_thread() is used to launch the init process during booting by
start_kernel()	//in init/main.c
But at that time, the process 0 which calls kernel_thread is executing in Kernel mode, so why should some process in kernel mode make a system call??



int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
{
	long retval, d0;

	__asm__ __volatile__(
		"movl %%esp,%%esi\n\t"
		"int $0x80\n\t"		/* Linux/i386 system call */
		"cmpl %%esp,%%esi\n\t"	/* child or parent? */
		"je 1f\n\t"		/* parent - jump */
		/* Load the argument into eax, and push it.  That way, it does
		 * not matter whether the called function is compiled with
		 * -mregparm or not.  */
		"movl %4,%%eax\n\t"
		"pushl %%eax\n\t"		
		"call *%5\n\t"		/* call fn */
		"movl %3,%0\n\t"	/* exit */
		"int $0x80\n"
		"1:\t"
		:"=&a" (retval), "=&S" (d0)
		:"0" (__NR_clone), "i" (__NR_exit),
		 "r" (arg), "r" (fn),
		 "b" (flags | CLONE_VM)
		: "memory");
	return retval;
}





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Qn: kernel_thread()
  2002-02-02 17:16 Qn: kernel_thread() Alpha Beta
@ 2002-02-02 22:09 ` Mark Zealey
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Zealey @ 2002-02-02 22:09 UTC (permalink / raw)
  To: linux-kernel

On Sat, Feb 02, 2002 at 10:46:20PM +0530, Alpha Beta wrote:

> In the code of 
> int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
> in arch/i386/kernel/process.c
> 
> as can be seen in the code here, a system call is made by trigerring the 0x80 interrupt.
> this function kernel_thread() is used to launch the init process during booting by
> start_kernel()	//in init/main.c
> But at that time, the process 0 which calls kernel_thread is executing in Kernel mode, so why should some process in kernel mode make a system call??

Easy way to get the registers dumped into memory

-- 

Mark Zealey
mark@zealos.org
mark@itsolve.co.uk

UL++++>$ G!>(GCM/GCS/GS/GM) dpu? s:-@ a16! C++++>$ P++++>+++++$ L+++>+++++$
!E---? W+++>$ N- !o? !w--- O? !M? !V? !PS !PE--@ PGP+? r++ !t---?@ !X---?
!R- b+ !tv b+ DI+ D+? G+++ e>+++++ !h++* r!-- y--

(www.geekcode.com)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-02-02 22:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-02 17:16 Qn: kernel_thread() Alpha Beta
2002-02-02 22:09 ` Mark Zealey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox