我想用QEMU调试我编译的内核linux-4.13.4上Ubuntu 16.04.3 LTS
我按照以下步骤操作:
sudo apt-get install qemu
Run Code Online (Sandbox Code Playgroud)
qemu-system-x86_64 -s -S -kernel /home/wxf/kernelSources/linux-4.13.4/arch/x86_64/boot/bzImage -initrd /boot/initrd.img-4.13.4
Run Code Online (Sandbox Code Playgroud)
注意:
--s -bdb tcp :: 1234的简写
-S在启动时冻结CPU(使用'c'开始执行)
但我收到以下警告:
warning: TCG doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
Run Code Online (Sandbox Code Playgroud)
终端停在那里,我无法输入其他命令.
运行时弹出QEMU窗口,但它已停止.
如何消除警告并且是正常的(因为它不是错误信息)?
我已经阅读了很多帖子并观看了几个 Youtube 视频 C++ 原子和内存模型(ConCpp 17、14)。
当我阅读Concurrency In Action 5.3.3 节RELAXED ORDERING一书时,我仍然无法理解作者在他的假设下提供的示例。
不仅仅是编译器可以重新排序指令。即使线程正在运行相同的代码位,由于在没有显式排序约束的情况下在其他线程中进行操作,它们可能会在事件顺序上产生分歧,因为不同的 CPU 缓存和内部缓冲区可以为相同的内存保存不同的值. 这很重要,我再说一遍:线程不必就事件的顺序达成一致。您不仅必须抛弃基于交错操作的心智模型,还必须抛弃基于编译器或处理器对指令重新排序的想法的心智模型。
假设我们看到的代码没有重新排序。
#include <atomic>
#include <thread>
#include <assert.h>
std::atomic<bool> x,y;
std::atomic<int> z;
void write_x_then_y()
{
x.store(true,std::memory_order_relaxed); // 1
y.store(true,std::memory_order_relaxed); // 2
}
void read_y_then_x()
{
while(!y.load(std::memory_order_relaxed)); // 3
if(x.load(std::memory_order_relaxed)) // 4
++z;
}
int main() {
x=false;
y=false;
z=0;
std::thread a(write_x_then_y);
std::thread b(read_y_then_x);
a.join();
b.join();
assert(z.load()!=0); // 5
}
Run Code Online (Sandbox Code Playgroud)
从这个链接:https : //www.developerfusion.com/article/138018/memory-ordering-for-atomic-operations-in-c0x/
为什么x.load(relaxed) …
TensorFlow 自动生成代码。我很好奇 TF 是如何生成gen_array_ops.py的array_ops.cc?
生成的python文件在 python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py
"""Python wrappers around TensorFlow ops.
This file is MACHINE GENERATED! Do not edit.
Original C++ source file: array_ops.cc
"""
...
...
Run Code Online (Sandbox Code Playgroud) 我正在尝试调试JDK9.
我想跟踪源代码并查看JDK/Hotspot代码的控制流程.
我使用gdb和Eclipse但是有一个问题SIGSEGV Segmentation fault.
我从JDK官方文档中按照Buildme.md配置JDK9,
bash ./configure --with-debug-level=slowdebug --with-target-bits=64
--disable-warnings-as-errors
Run Code Online (Sandbox Code Playgroud)
然后,
make all
Run Code Online (Sandbox Code Playgroud)
我得到我的自定义调试版本:
/images/jdk/bin/java -version openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-adhoc.xfwu.9dev)
OpenJDK 64-Bit Server VM (build 9-internal+0-adhoc.xfwu.9dev, mixed mode)
Run Code Online (Sandbox Code Playgroud)
以下代码段显示我使用HelloWorld.java来调试代码.我start是gdb.乍一看似乎很好.但是,当这个程序开始运行时thread 2,它会引发问题SIGSEGV Segmentation fault.我不知道为什么以及如何解决它.同样,我使用Eclipse进行调试,实际上,它与gdb没什么不同.从根本上说,他们都使用gdb.然后我得到同样的问题.
Thread 2 "java" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7fc8700 (LWP 24030)]
0x00007fffe0dde513 in ?? ()
(gdb) info thread
Id Target Id Frame
1 Thread 0x7ffff7fc9700 (LWP 24012) "java" 0x00007ffff71c99cd in …Run Code Online (Sandbox Code Playgroud) ...
if (GCLocker::check_active_before_gc()) {
return false;
}
...
Run Code Online (Sandbox Code Playgroud)
如您所见,如果GCLocker::check_active_before_gc()为true,则它不会调用次要GC,即PSScavenge::invoke_no_policy()。为什么?
bool GCLocker::check_active_before_gc() {
assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
if (is_active() && !_needs_gc) {
verify_critical_count();
_needs_gc = true;
log_debug_jni("Setting _needs_gc.");
}
return is_active();
}
Run Code Online (Sandbox Code Playgroud)
// Accessors
static bool is_active() {
assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
return is_active_internal();
}
Run Code Online (Sandbox Code Playgroud)
static bool is_active_internal() {
verify_critical_count();
return _jni_lock_count > 0;
}
Run Code Online (Sandbox Code Playgroud)
static volatile jint _jni_lock_count; // number of jni active instances.
Run Code Online (Sandbox Code Playgroud)
该 …
我将为 Java 社区做出贡献,并且我对 JVM 很感兴趣。
\n\n现在我想下载最新的 JVM Hotspot 源代码并跟踪更新。
\n\n首先,我访问http://openjdk.java.net/。
\n\n在它的左侧我发现一些有用的标签
\n\nSource code: \nMercurial \nBundles\n...\nJDK 6\nJDK 7\nJDK 7 Updates\nJDK 8 \xc2\xb7 Java SE 8\nJDK 8 Updates\nJDK 9 \xc2\xb7 Java SE 9\nJDK 10\nRun Code Online (Sandbox Code Playgroud)\n\n我只能找到有关如何下载JDK8u源代码的说明:http://openjdk.java.net/projects/jdk8u/
\n\n我们开放修复 jdk8u-dev 森林中的 8u152。(发帖时间为2017-06-06 14:23:36)
可以使用以下命令克隆用于持续开发的 jdk8u-dev 林:hg clone http://hg.openjdk.java.net/jdk8u/jdk8u-dev;cd jdk8u-dev;sh get_source.sh .
可以使用以下命令克隆相应的主林jdk8u:hg clone http://hg.openjdk.java.net/jdk8u/jdk8u;cd jdk8u;sh get_source.sh .
此外,可以通过克隆 8u 主林http://hg.openjdk.java.net/jdk8u/jdk8u并使用 \' jdk8u102-b14\' …
"
typedef NOT_LP64(uint16_t) LP64_ONLY(uint32_t) idx_t;
"是什么意思?
代码来自jdk8 , taskqueue.hpp.
我不明白上面的语法.
我找到了很多解释typedef type name,但他们没有解释上述情况.
NOT_LP64并LP64_ONLY在macro.hpp文件中定义.
#ifdef _LP64
#define LP64_ONLY(code) code
#define NOT_LP64(code)
#else // !_LP64
#define LP64_ONLY(code)
#define NOT_LP64(code) code
#endif // _LP64
Run Code Online (Sandbox Code Playgroud) 我想要做的是:将foo函数指针bar作为默认参数传递给函数。但这是不允许的。如何实施?
class Klass ():
def __init__(self):
print('init')
def foo(self):
print('foo')
def bar(self, func=self.foo): # error here
func()
print('bar')
Run Code Online (Sandbox Code Playgroud) 如何理解以下std::stringinit语法?
#include <iostream>
#include <string>
int main ()
{
std::string y;
std::string x = "x str";
new (&y) std::string(x);
std::cout << y << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
x str
Run Code Online (Sandbox Code Playgroud)
我们可以将语句分为两个步骤吗?
1。
string* temp = new std::string(x);
Run Code Online (Sandbox Code Playgroud)
2。
(&y) = temp
Run Code Online (Sandbox Code Playgroud)
因此,原始语句只是步骤1 + 2的快捷方式。
参考:
1. https://en.cppreference.com/w/cpp/string/basic_string/basic_string
c++ ×4
jvm-hotspot ×3
java ×2
jvm ×2
python ×2
atomic ×1
c ×1
class ×1
constructor ×1
debugging ×1
eclipse ×1
linux ×1
linux-kernel ×1
memory-model ×1
openjdk ×1
qemu ×1
string ×1
syntax ×1
tensorflow ×1
typedef ×1