Linux - System Image and Process Image

System image (系统映像)

在计算机领域,系统映像是以某种非易失性形式(如文件)存储的计算机系统整个状态的序列化副本。如果一个系统能够被关闭,并在之后恢复到完全相同的状态,那么就可以说它能够使用系统映像。在这种情况下,系统映像可用于备份。

一个例子是许多操作系统的休眠功能。休眠使用整个机器的RAM作为一个映像。这时,所有RAM内存的状态被存储到磁盘上,之后计算机进入节能模式,然后再恢复到正常操作。

In computing, a system image is a serialized copy of the entire state of a computer system stored in some non-volatile form such as a file. A system is said to be capable of using system images if it can be shut down and later restored to exactly the same state. In such cases, system images can be used for backup.

An example would be the hibernate feature of many operating systems. Hibernation uses an image of the entire machine's RAM. Here, the state of all RAM memory is stored to disk, the computer is brought into an energy saving mode, then later restored to normal operation.

Process Image (进程映像)

进程映像是一个给定的进程在某个时间点的状态的副本。它经常被用来在一个不断变化的系统中生成一个某时刻的状态副本,并持久性保存下来。

一个比较常见的例子是数据库管理系统,DBMS。大多数DBMS可以在关闭前将其数据库的状态存储到一个文件中(见数据库转存)。然后,DBMS可以在数据库中的信息完好无损的情况下重新启动,并像软件从未停止过一样继续进行。

一些仿真器提供了一个保存被仿真系统映像的功能。在视频游戏中,这通常被称为savestate。

另一个用途是代码移动性:移动代理可以通过保存其状态在机器之间迁移,然后将数据复制到另一台机器并在那里重新启动。

我们使用core dump出来的是进程映像,其结构和系统映像是类似的。

A process image is a copy of a given process's state at a given point in time. It is often used to create persistence within an otherwise volatile system.

Most DBMS can store the state of its database or databases to a file before being closed down (see database dump). The DBMS can then be restarted later with the information in the database intact and proceed as though the software had never stopped.

Some emulators provide a facility to save an image of the system being emulated. In video gaming this is often referred to as a savestate.

Another use is code mobility: a mobile agent can migrate between machines by having its state saved, then copying the data to another machine and restarting there.

Although its purpose is different, a "system image" is often similar in structure to a core dump.

Process Image 详细说明

进程映像是执行程序时需要的一个可执行文件,这个是进程实时在使用的一个文件,而上面所说的映像指的是一种将此文件转存的情况。

该映像通常包含以下部分:

- 代码段或文本段 // Code segment or text segment

- 数据段  //  Data segment

- 堆栈段 // Stack segment

- 堆段    // Heap segment

下面是进程映像的图形表示:

Code segment

代码段是编译后得到的object(目标)文件的一部分,里面包含可执行指令,会放在程序的虚拟地址空间中。这通常是只读的数据段,有一个固定的大小。

Data segment

数据段分两种类型:

- 初始化的 (Initialized)

- 未初始化的 (Un-initialized)

初始化数据段是object文件中的一部分,里面包含的是带有初始值的静态或全局变量,也会放在程序的虚拟地址空间中。

未初始化的数据段是object文件中的一部分,里面包含的是没有初始化的静态或全局变量,也会放在程序的虚拟地址空间中。未初始化的数据段也被称为BSS(由符号开始的块, Block Started by Symbol)段。

数据段是可读可写的,因为变量的值在运行期间可以被改变。这个段也有一个固定的大小。

Stack segment

堆栈段是一个分配给自动变量和函数参数的内存区域。在执行函数调用时,它还存储了一个返回地址。堆栈使用LIFO(Last-In-First-Out)机制来存储本地或自动变量、函数参数和存储下一个地址或返回地址。返回地址指的是函数执行完成后返回的地址。这个段的大小是根据本地变量、函数参数和函数调用而变化的。这个段所占用空间的增长方向,是从较高的地址向较低的地址。

Heap segment

堆段是分配给动态内存存储的内存区域,例如用于malloc()和calloc()调用。这个段的大小也是根据用户分配而变化的。这个段从一个较低的地址增长到一个较高的地址。

现在让我们检查一下段(数据段和bss段)的大小在几个示例程序中是如何变化的。段的大小可以通过执行 "size "命令来了解。

File: segment_size1.c

#include<stdio.h>

int main() {

   printf("Hello World\n");

   return 0;

}

在下面的程序中,增加了一个未初始化的静态变量。这意味着未初始化段(BSS)的大小将增加4字节。注意 - 在Linux操作系统中,int的大小是4字节。整数数据类型的大小取决于编译器和操作系统的支持。

File: segment_size2.c

#include<stdio.h>

int main() {

   static int mystaticint1;

   printf("Hello World\n");

   return 0;

}

在下面的程序中,增加了一个初始化的静态变量。这意味着初始化段(DATA)的大小将增加4字节。

File: segment_size3.c

#include<stdio.h>

int main() {

   static int mystaticint1;

   static int mystaticint2 = 100;

   printf("Hello World\n");

   return 0;

}

在下面的程序中,增加了一个初始化的全局变量。这意味着初始化段(DATA)的大小将增加4字节。

File: segment_size4.c

#include<stdio.h>

int myglobalint1 = 500;

int main() {

   static int mystaticint1;

   static int mystaticint2 = 100;

   printf("Hello World\n");

   return 0;

}

在下面的程序中,增加了一个未初始化的全局变量。这意味着未初始化段(BSS)的大小将增加4字节。

File: segment_size5.c

#include<stdio.h>

int myglobalint1 = 500;

int myglobalint2;

int main() {

   static int mystaticint1;

   static int mystaticint2 = 100;

   printf("Hello World\n");

   return 0;

}

执行测试:

先编译:

$ gcc segment_size1.c -o segment_size1

$ gcc segment_size2.c -o segment_size2

$ gcc segment_size3.c -o segment_size3

$ gcc segment_size4.c -o segment_size4

$ gcc segment_size5.c -o segment_size5

输出结果:

$size segment_size1 segment_size2 segment_size3 segment_size4 segment_size5

   text  data  bss  dec  hex  filename

   878   252    8   1138 472  segment_size1

   878   252   12   1142 476  segment_size2

   878   256   12   1146 47a  segment_size3

   878   260   12   1150 47e  segment_size4

   878   260   16   1154 482  segment_size5

参考:

Process Image

https://en.wikipedia.org/wiki/System_image

 

The error message "Abort get_format -------- 0 -------- Wrong Image Format for bootm command ERROR: can't get kernel image!" typically occurs during the boot process of a Linux system, specifically when trying to load an image (kernel) using the 'bootm' command. The "get_format" is likely referring to the stage where the bootloader is attempting to determine the format of the image file being loaded. Here's a breakdown of the error: 1. "Abort": This suggests that the process has stopped abruptly, indicating a failure. 2. "get_format": The bootloader failed to identify the correct format of the kernel image file it is trying to load. 3. "0": A numeric code or status, but without further context, it's not clear what this exactly means. 4. "Wrong Image Format": The issue is that the image being loaded is in an unsupported or incorrect format for the current boot environment. 5. "can't get kernel image": Unable to fetch or load the kernel into memory for the boot process. Possible reasons and solutions: - Check the kernel image: Ensure that you have the correct kernel file in a compatible format (e.g., compressed with the appropriate compression method, like .bin or .elf). - Bootloader configuration: Verify that the bootloader is configured to load the right kind of kernel images and knows where to find them. - Partitioning issues: Check if the partition containing the kernel image is correctly set as the boot partition or if its file system is recognized by the bootloader. - Mismatched versions: Make sure your bootloader (e.g., grub, u-boot) and kernel are compatible.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值