6 PROCESSES

6.1 Processes and Programs

A program is a file containing a range of information that describes how to construct a process at run time.

This information includes the following:
? Binary format identification: Each program file includes metainformation describing the format of the executable file. This enables the kernel to interpret the remaining information in the file. Historically, two widely used formats for UNIX executable files were the original a.out (“assembler output”) format and the later, more sophisticated COFF (Common Object File Format). Nowadays, most UNIX implementations (including Linux) employ the Executable and Linking Format (ELF), which provides a number of advantages over the older formats.

? Machine-language instructions: These encode the algorithm of the program.
? Program entry-point address: This identifies the location of the instruction at which execution of the program should commence.
? Data: The program file contains values used to initialize variables and also literal constants used by the program (e.g., strings).
? Symbol and relocation tables: These describe the locations and names of functions and variables within the program. These tables are used for a variety of purposes, including debugging and run-time symbol resolution (dynamic linking).
? Shared-library and dynamic-linking information: The program file includes fields listing the shared libraries that the program needs to use at run time and the pathname of the dynamic linker that should be used to load these libraries.
? Other information: The program file contains various other information that describes how to construct a process.

 

----------------------------------------------------------------------------------------------------------------------------------

6.3 Memory Layout of a Process
The memory allocated to each process is composed of a number of parts, usually referred to as segments. These segments are as follows:
? The text segment contains the machine-language instructions of the program run by the process. The text segment is made read-only so that a process doesn’t accidentally modify its own instructions via a bad pointer value. Since many processes may be running the same program, the text segment is made sharable so that a single copy of the program code can be mapped into the virtual address space of all of the processes.
? The initialized data segment contains global and static variables that are explicitly initialized. The values of these variables are read from the executable file when the program is loaded into memory.
? The uninitialized data segment contains global and static variables that are not explicitly initialized. Before starting the program, the system initializes all memory in this segment to 0. For historical reasons, this is often called the bss segment, a name derived from an old assembler mnemonic for “block started by symbol.” The main reason for placing global and static variables that are initialized into a separate segment from those that are uninitialized is that, when a program is stored on disk, it is not necessary to allocate space for the uninitialized data. Instead, the executable merely needs to record the location and size required for the uninitialized data segment, and this space is allocated by the program loader at run time.
? The stack is a dynamically growing and shrinking segment containing stack frames. One stack frame is allocated for each currently called function. A frame stores the function’s local variables (so-called automatic variables), arguments, and return value. Stack frames are discussed in more detail in Section 6.5.
? The heap is an area from which memory (for variables) can be dynamically allocated at run time. The top end of the heap is called the program break.

-----------------------------------------------------------------------------------------------------------------

Virtual memory management separates the virtual address space of a process from the physical address space of RAM.

This provides many advantages:
? Processes are isolated from one another and from the kernel, so that one process can’t read or modify the memory of another process or the kernel. This is accomplished by having the page-table entries for each process point to distinct sets of physical pages in RAM (or in the swap area).


? Where appropriate, two or more processes can share memory. The kernel makes this possible by having page-table entries in different processes refer to the same pages of RAM. Memory sharing occurs in two common circumstances:
– Multiple processes executing the same program can share a single (readonly) copy of the program code. This type of sharing is performed implicitly when multiple programs execute the same program file (or load the same shared library).


– Processes can use the shmget() and mmap() system calls to explicitly request sharing of memory regions with other processes. This is done for the purpose of interprocess communication.


? The implementation of memory protection schemes is facilitated; that is, pagetable entries can be marked to indicate that the contents of the corresponding page are readable, writable, executable, or some combination of these protections.
Where multiple processes share pages of RAM, it is possible to specify that each process has different protections on the memory; for example, one process might have read-only access to a page, while another has read-write access.


? Programmers, and tools such as the compiler and linker, don’t need to be concerned with the physical layout of the program in RAM.


? Because only a part of a program needs to reside in memory, the program loads and runs faster. Furthermore, the memory footprint (i.e., virtual size) of a process can exceed the capacity of RAM. One final advantage of virtual memory management is that since each process uses less RAM, more processes can simultaneously be held in RAM. This typically leads to better CPU utilization, since it increases the likelihood that, at any moment in time, there is at least one process that the CPU can execute.

-------------------------------------------------------------------------------------------------------

Command-Line Arguments (argc, argv)

The first argument, int argc, indicates how many command-line arguments there are.

The second argument, char *argv[], is an array of pointers to the command-line arguments, each of which is a null-terminated
character string. The first of these strings, in argv[0], is (conventionally) the name of the program itself. The list of pointers in argv is terminated by a NULL pointer (i.e., argv[argc] is NULL).

 

------------------------------------------------------------------------------------------------------------------------------------

Summary
Each process has a unique process ID and maintains a record of its parent’s process ID.
The virtual memory of a process is logically divided into a number of segments: text, (initialized and uninitialized) data, stack, and heap.
The stack consists of a series of frames, with a new frame being added as a function is invoked and removed when the function returns. Each frame contains the local variables, function arguments, and call linkage information for a single function invocation.

The command-line arguments supplied when a program is invoked are made available via the argc and argv arguments to main(). By convention, argv[0] contains the name used to invoke the program.

Each process receives a copy of its parent’s environment list, a set of name-value pairs. The global variable environ and various library functions allow a process to access and modify the variables in its environment list.

The setjmp() and longjmp() functions provide a way to perform a nonlocal goto from one function to another (unwinding the stack). In order to avoid problems with compiler optimization, we may need to declare variables with the volatile modifier when making use of these functions. Nonlocal gotos can render a program difficult to read and maintain, and should be avoided whenever possible.

### 回答1: solver processes是指在计算机系统中用于解决问题或处理特定任务的进程。在计算机领域中,问题求解或任务处理是一个常见的需求,通过使用solver processes,可以提高问题解决的效率和准确性。 solver processes通常运行在计算机系统的后台,执行各种算法和策略来处理特定的问题。它们可以处理各种类型的问题,例如数学计算、数据分析、优化、搜索等。这些进程通常具有较高的计算能力和算法优化,能够在较短的时间内得出问题的解决方案。 solver processes通常具有以下特点: 1. 并行处理:solver processes可以同时处理多个问题,通过充分利用计算机的多核处理能力来提高问题的解决速度。 2. 灵活性:solver processes可以根据不同的需求来选择合适的算法和策略,以达到最佳的问题解决效果。 3. 可扩展性:solver processes可以根据需要进行扩展,以适应更大规模的问题或任务处理要求。 4. 自动化:solver processes通常具有自动化的特性,能够自动检测问题并选择合适的解法来解决,无需用户的干预。 在实际应用中,solver processes被广泛应用于各个领域,例如科学研究、工程设计、金融分析等。它们可以帮助用户解决复杂的问题,提高决策的准确性和效率。 总之,solver processes是计算机系统中用于解决问题或处理特定任务的进程,具有并行处理、灵活性、可扩展性和自动化等特点。它们在不同领域中的应用,可以提高问题解决的效率和准确性。 ### 回答2: Solver processes是指解决问题的过程,更具体地说,它是指以求解数学、物理、工程、计算机科学等领域中复杂问题为目标的一系列逻辑和计算步骤。 在实际应用中,solver processes可以用来解决一些经典的优化问题,比如在物流行业中的车辆路径规划问题,或者在电力系统中的最优电源调度问题。它们的目标是通过寻找最优的解决方案来提高效率、降低成本,或者优化某种特定的性能指标。 Solver processes的步骤通常包括以下几个方面:问题建模、算法选择、参数设置、运算求解和结果验证。 首先,问题建模阶段需要将实际问题转化为数学模型,确定因变量和约束条件,以及目标函数。这一步是整个过程的基础,决定了后续求解过程的可行性和准确性。 接下来,需要选择合适的算法来解决问题。不同的问题可能需要不同的求解方法,如线性规划、整数规划、动态规划、遗传算法等。算法的选择要根据问题的性质和规模来决定。 在算法选择后,需要设置合适的参数,如收敛准则、最大迭代次数等,以确保算法的效果和求解的精度。 然后,运算求解是整个过程的核心步骤。通过计算机和数值计算方法,根据初始条件和问题设置,进行迭代计算,不断优化求解过程,最终得到问题的近似解。 最后,在求解完成后,需要进行结果验证,以确保解的合理性。这可以通过对比解与实际问题的对应关系,或者通过敏感性分析等方法来进行。 总结来说,solver processes是一种解决问题的过程,通过建模、算法选择、参数设置、运算求解和结果验证等步骤,来寻找最优解决方案,提高效率和优化性能。这对于许多领域中的复杂问题都具有重要的应用价值。 ### 回答3: Solver processes是指求解器处理过程,是指计算机程序中使用的一种算法或方法,用于解决数学问题或优化问题。 在计算机科学和运筹学中,solver processes通常被用于解决诸如线性规划、非线性规划、图论等各种数学问题。这些问题通常涉及到在给定的约束条件下,寻找一个最优解或近似最优解。 solver processes通常包括以下几个步骤: 1. 建立数学模型:根据实际问题,将问题抽象为数学模型,包括目标函数和约束条件。 2. 选择求解算法:根据问题的特点和求解的要求,选择适合的求解算法,比如线性规划可以使用单纯形算法,非线性规划可以使用梯度下降法等。 3. 算法实现:将选择的求解算法翻译成具体的计算机程序,包括编写代码、数据结构的定义等。 4. 输入数据:将问题中的相关数据输入到程序中,作为算法的输入。 5. 执行求解:程序根据输入的数据,执行求解算法,计算出最优解或近似最优解。 6. 输出结果:将求解结果反馈给用户,可以是数值结果、图形结果等。 solver processes在实际应用中具有广泛的应用,比如在物流配送中优化车辆路径、在生产计划中优化资源配置、在金融风险管理中优化投资组合等。它们能够提高问题求解的效率和质量,为决策提供科学依据。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值