当前位置:网站首页>Process virtual address space partition
Process virtual address space partition
2022-04-23 12:46:00 【New code spa technician】
Process virtual address space area division
Before we write a program in a language , There are two things : Instructions and data . After we compile the link , Generate an executable file and store it on our disk , When you run this program , Will load the program into memory .
And in the process of loading , What contents of the executable file are loaded into memory ? How is it stored when loaded into memory ? Which areas are divided into ? How to divide ?
Before that, we need to know , Programs cannot be loaded directly into physical memory !
Let's say X86 32 position Linux Environment as an example .
When the program is executed ,Linux The system will assign a to the current process 2^32(4G) The size of a space , This space is the virtual address space of the process , It has all the resources for the process , All resources constitute the division of state .
This space is divided into two parts by default : User space and kernel space , The user space is occupied by default 3G Size space , The default size of kernel space is 1G.
All processes in the system have an address space .
In user space , The system is not from 0 Address (0x00000000) Start storing resources , stay 0x00000000 To 0x08048000 This memory cannot be accessed , So when dereferencing a null pointer, the program will crash .
The next memory segment stores .text Paragraph and .rodata paragraph ..text The segment stores instructions ,.rodata The segment stores read-only data , For example, the string constant defined in the program char* str = "hello world";
, The resources of these two paragraphs are read-only resources , When we try to modify the data of these two paragraphs , The program will collapse directly .
The next thing to store is .data Paragraph and .bss paragraph ,.data The segment store is initialized and the value is not 0 And static variables , and .bss The segment store is uninitialized or initialized to 0 And static variables .
What follows is .heap Heap memory segment , The space dynamically requested by the program is in this memory .
If the program is linked to a dynamic library , The memory behind the heap memory is used to load the shared library .
Next is the function operation 、 Or when opening threads stack Stack space , Different from other memory segments , The growth direction of stack space is opposite to that of other segments , From high address to low address .
The last memory segment stores command line parameters and environment variables .
Intercepted from 《 Learn more about computer systems 》.
The user space of each process is private , But kernel space is shared !
版权声明
本文为[New code spa technician]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231244365157.html
边栏推荐
- STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
- 98. Error s.e.errormvcautoconfiguration $staticview reported by freemaker framework: cannot render error page for request
- Hard core parsing promise object (do you know these seven common APIs and seven key questions?)
- 4. DRF permission & access frequency & filtering & sorting
- Use source insight to view and edit source code
- Stm32cubeprogrammer basic instructions
- SSM框架系列——注解开发day2-2
- 在线计算过往日期天数,计算活了多少天
- Try the server for one month for free, and attach the tutorial
- Zero trust in network information security
猜你喜欢
随机推荐
Image attribute of input: type attribute of fashion cloud learning -h5
STM32控制步进电机(ULN2003+28byj)
Why is the premise of hash% length = = hash & (length-1) that length is the nth power of 2
Number of nodes of complete binary tree
天梯赛赛前练习
大家帮我看一下这是啥情况,MySQL5.5的。谢了
在线计算过往日期天数,计算活了多少天
The continuous construction of the Internet industry platform is not only able to collect traffic
Deploying MySQL in cloud native kubesphere
SSL证书退款说明
QT draw image
XinChaCha Trust SSL Organization Validated
【csnote】ER图
SSM框架系列——数据源配置day2-1
MySQL function - recursive function
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
【每日一题】棋盘问题
Buuctf Web [gxyctf2019] no dolls
leetcode:437. 路径总和 III【dfs 选还是不选?】
Please help me see what this is, mysql5 5. Thanks