Progress 和 Thread 以及 Module

本文深入解析了Windows环境下模块、进程及线程的概念。模块指DLL或EXE文件,代表一个文件的所有代码和资源。进程代表运行的应用程序实例,包含至少一个主线程。文章还讨论了进程内的堆和线程的栈,以及DLL和EXE如何通过设置使用相同的CRT来实现在不同空间上的内存分配。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

模块 和 进程: 模块为win32概念。一个模块为一个DLL文件或EXE文件。代表一个文件的所有代码和资源。磁盘上的文件不是模块,载入内存就是模块。

进程 和 线程: progress代表一个运行的应用程序(或是一个应用程序的实例), 进程是惰性:不执行任何代码,由主线程在进程的环境内执行相应的代码(至少一个主线程,可以多个Thread),模块和进程没有区别

进程有堆,线程有栈:一个进程有一个主线程。所以进程(模块)会有一个堆(new分配的内存)和一个栈(局部变量)与之绑定。(堆栈大小由编译器决定)。一个DLL或EXE拥有不同的堆(当DLL和EXE混用动态链接库和静态链接库时会出现两个CRT有不同的堆),使得在一个堆上分配的内存不能再另一个堆上释放。

--》DLL和EXE有不同的堆本质: 两个模块拥有不同的CRT。
--《Windows 下设置VS工程属性运行库设置为: 多线程DLL(MD)。EXE和DLL就使用同一个CRT(MSVCRT.DLL),所以可以在同一块空间上new和delete。即在DLL上new在EXE中delete。

参见:点击打开链接


进程内模块和进程外模块: 进程内模块共享内存,比如进程加载的DLL其实就是一个模块。进程外模块 和进程一样,单独运行。也包括DLL
--------------------------------------------------------------------------- SystemError Traceback (most recent call last) <ipython-input-10-acafba07b263> in <module> ----> 1 import shap 2 # 模型解释 3 def explain_model(df): 4 X = df[['RAM', 'Battery Capacity']] 5 y = df['Price'] > df['Price'].median() D:\anaconda3\lib\site-packages\shap\__init__.py in <module> 10 warnings.warn("As of version 0.29.0 shap only supports Python 3 (not 2)!") 11 ---> 12 from ._explanation import Explanation, Cohorts 13 14 # explainers D:\anaconda3\lib\site-packages\shap\_explanation.py in <module> 10 from slicer import Slicer, Alias, Obj 11 # from ._order import Order ---> 12 from .utils._general import OpChain 13 14 # slicer confuses pylint... D:\anaconda3\lib\site-packages\shap\utils\__init__.py in <module> ----> 1 from ._clustering import hclust_ordering, partition_tree, partition_tree_shuffle, delta_minimization_order, hclust 2 from ._general import approximate_interactions, potential_interactions, sample, safe_isinstance, assert_import, record_import_error 3 from ._general import shapley_coefficients, convert_name, format_value, ordinal_str, OpChain, suppress_stderr 4 from ._show_progress import show_progress 5 from ._masked_model import MaskedModel, make_masks D:\anaconda3\lib\site-packages\shap\utils\_clustering.py in <module> 2 import scipy as sp 3 from scipy.spatial.distance import pdist ----> 4 from numba import jit 5 import sklearn 6 import warnings D:\anaconda3\lib\site-packages\numba\__init__.py in <module> 41 42 # Re-export vectorize decorators and the thread layer querying function ---> 43 from numba.np.ufunc import (vectorize, guvectorize, threading_layer, 44 get_num_threads, set_num_threads) 45 D:\anaconda3\lib\site-packages\numba\np\ufunc\__init__.py in <module> 1 # -*- coding: utf-8 -*- 2 ----> 3 from numba.np.ufunc.decorators import Vectorize, GUVectorize, vectorize, guvectorize 4 from numba.np.ufunc._internal import PyUFunc_None, PyUFunc_Zero, PyUFunc_One 5 from numba.np.ufunc import _internal, array_exprs D:\anaconda3\lib\site-packages\numba\np\ufunc\decorators.py in <module> 1 import inspect 2 ----> 3 from numba.np.ufunc import _internal 4 from numba.np.ufunc.parallel import ParallelUFuncBuilder, ParallelGUFuncBuilder 5 SystemError: initialization of _internal failed without raising an exception
06-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值