从哪里为Linux进程分配堆栈内存? [英] Where is the stack memory allocated from for a Linux process?

查看:412
本文介绍了从哪里为Linux进程分配堆栈内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们知道,当创建一个进程时,会为此进程分配一个堆栈.在Linux中,堆栈的大小通常为8 Mb.我的问题是,从哪里分配此堆栈?是从用户空间还是从系统空间?

We know that when a process is created,one stack is allocated for this process.The size of the stack is typically 8 Mb in linux.My question is that,from where this stack is allocated??From user space or from system space?

推荐答案

我希望您知道所有用户进程将仅保留在用户空间中的概念.它使用系统调用来完成内核的某些工作.

I hope you know the concept that all user process will be kept in user space only. It uses system calls to get some work done by kernel.

堆栈内存将成为内存中进程上下文区域的一部分.即用户空间.

The stack memory will be part of process context area in memory. i.e user space.

假设您的进程正在运行,请通过ps -ax获取PID.说1234是您的PID.

Suppose your process is running, get the PID by ps -ax. say 1234 is your PID.

cat /proc/1234/maps将为您提供该特定进程的映射.

cat /proc/1234/maps will give you the mapping of that particular process.

在thats映射文件中,您可以检查stack进行堆栈映射.

In thats maps file, you can check the stack for stack mapping.

这篇关于从哪里为Linux进程分配堆栈内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆