当前位置:网站首页>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
边栏推荐
猜你喜欢

【unity笔记】L4Unity中的基础光照

S2-062 remote command execution vulnerability recurrence (cve-2021-31805)

Idea的src子文件下无法创建servlet

【每日一题】棋盘问题

mysql中 innoDB执行过程分析

Introduction to metalama 4 Use fabric to manipulate items or namespaces

SSL certificate refund instructions

【蓝桥杯】4月17日省赛刷题训练(前3道题)

Use source insight to view and edit source code

NPDP|产品经理如何做到不会被程序员排斥?
随机推荐
QT interprocess communication
Please help me see what this is, mysql5 5. Thanks
Dialogue with Bruce, author of PostgreSQL: "changing careers" is to better move forward
Kubernets Getting started tutoriel
解锁OpenHarmony技术日!年度盛会,即将揭幕!
Bert base Chinese Download (SMART)
Can I take the CPDA data analyst certificate for 0 foundation
SQLserver怎么插入或更新当天的星期数,bit而不是文本
网络信息安全之零信任
SSM框架系列——Junit单元测试优化day2-3
Stacks and queues a
[wechat applet] Z-index is invalid
uni-app 原生APP-云打包集成极光推送(JG-JPUSH)详细教程
Introduction to kubernetes
How much does software testing help reduce program bugs?
Uni app native app local packaging integrated Aurora push (jg-jpush) detailed tutorial
Number of nodes of complete binary tree
Luogu p3236 [hnoi2014] picture frame solution
NBIOT的AT指令
Hard core parsing promise object (do you know these seven common APIs and seven key questions?)