- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在处理线程并且有一个潜在的死锁问题。有人向我提到装载机锁。
我在网上找不到太多信息。有人可以帮我解释一下“什么是加载器锁”吗?
最佳答案
例如,复习这个问题:
The general idea of loader lock: The system runs the code in
DllMain
inside a lock (as in - synchronization lock). Therefore, running non-trivial code insideDllMain
is "asking for a deadlock"
我提到的答案是基于这篇文章:
Another reason not to do anything scary in your DllMain
: Inadvertent deadlock
Your DllMain function runs inside the loader lock, one of the few times the OS lets you run code while one of its internal locks is held. This means that you must be extra careful not to violate a lock hierarchy in your
DllMain
; otherwise, you are asking for a deadlock.The loader lock is taken by any function that needs to access the list of DLLs loaded into the process. This includes functions like
GetModuleHandle
andGetModuleFileName
. If yourDllMain
enters a critical section or waits on a synchronization object, and that critical section or synchronization object is owned by some code that is in turn waiting for the loader lock, you just created a deadlock:
// global variable
CRITICAL_SECTION g_csGlobal;
// some code somewhere
EnterCriticalSection(&g_csGlobal);
... GetModuleFileName(MyInstance, ..);
LeaveCriticalSection(&g_csGlobal);
BOOL WINAPI
DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
LPVOID lpvReserved)
{
switch (fdwReason) {
...
case DLL_THREAD_DETACH:
EnterCriticalSection(&g_csGlobal);
...
}
...
}
请阅读整篇文章以充分理解。
关于windows - 什么是装载机锁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13874324/
我在一项 Activity 中使用了一个装载机。我能够启动加载程序并调用 onLoadFinished。当我更新数据并在加载程序中调用 onContentChanged 时,我看到 loadInBac
我正在尝试使用 liac-arff 库将 .arff 文件加载到 numpy 数组中。 ( https://github.com/renatopp/liac-arff ) 这是我的代码。 import
我最近在 three.js 中尝试了一些使用 Blender 和 Collada Loader 的实验。在我的 Blender 场景中,我有三个对象,但当然我只能使用 three.js 和加载器管理一
我正在通过 将 Parquet 数据加载到数据框中 spark.read.parquet('hdfs:///path/goes/here/...') 由于 parquet 分区,该路径中约有 50k
我是一名优秀的程序员,十分优秀!