博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
慢慢欣赏linux 进程创建的时候堆栈的建立
阅读量:4069 次
发布时间:2019-05-25

本文共 1889 字,大约阅读时间需要 6 分钟。

慢慢欣赏linux 进程创建的时候堆栈的建立long _do_fork(unsigned long clone_flags,	      unsigned long stack_start,	      unsigned long stack_size,	      int __user *parent_tidptr,	      int __user *child_tidptr,	      unsigned long tls){	p = copy_process(clone_flags, stack_start, stack_size,			 child_tidptr, NULL, trace, tls, NUMA_NO_NODE);	=>struct task_struct *copy_process(					unsigned long clone_flags,					unsigned long stack_start,					unsigned long stack_size,					int __user *child_tidptr,					struct pid *pid,					int trace,					unsigned long tls,					int node)	{		p = dup_task_struct(current, node);		=>struct task_struct *dup_task_struct(struct task_struct *orig, int node)		{			struct task_struct *tsk = alloc_task_struct_node(node);			unsigned long *stack = alloc_thread_stack_node(tsk, node);						tsk->stack = stack;			set_task_stack_end_magic(tsk);			=>void set_task_stack_end_magic(struct task_struct *tsk)			{				unsigned long *stackend;				stackend = end_of_stack(tsk);				*stackend = STACK_END_MAGIC;	/* for overflow detection */			}		}	}		retval = copy_thread_tls(clone_flags, stack_start, stack_size, p, tls);	=>int copy_thread_tls(unsigned long clone_flags, unsigned long sp,	unsigned long arg, struct task_struct *p, unsigned long tls)	{		struct pt_regs *childregs = task_pt_regs(p);		=>#define task_pt_regs(task) \		({									\			unsigned long __ptr = (unsigned long)task_stack_page(task);	\			__ptr += THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING;		\			((struct pt_regs *)__ptr) - 1;					\		})		=>void *task_stack_page(const struct task_struct *task)		{			return task->stack;		}				struct fork_frame *fork_frame = container_of(childregs, struct fork_frame, regs);		struct inactive_task_frame *frame = &fork_frame->frame;		frame->bp = 0;		frame->ret_addr = (unsigned long) ret_from_fork;		p->thread.sp = (unsigned long) fork_frame;		p->thread.sp0 = (unsigned long) (childregs+1);	}}

 

转载地址:http://kdlji.baihongyu.com/

你可能感兴趣的文章
OS + Unix Solaris / openSolaris
查看>>
db sql montior
查看>>
Unix + SCO UnixWare
查看>>
db db2 books
查看>>
read humor_campus
查看>>
my read_soft
查看>>
my pdfs
查看>>
framework Schedule Quartz
查看>>
IBM WebSphere Commerce Analyzer
查看>>
Unix + OS IBM Aix System Director
查看>>
Unix + OS IBM Aix FTP / wu-ftp / proftp
查看>>
framework apache commons
查看>>
my read work
查看>>
blancerServer IBM WebSphere Edge Server 6.1
查看>>
db db2 base / instance database tablespace container
查看>>
my read _job
查看>>
hd disk / disk raid / disk io / iops / iostat / iowait / iotop / iometer
查看>>
project ASP.NET
查看>>
db db2_monitorTool IBM Rational Performace Tester
查看>>
OS + Unix Aix telnet
查看>>