我们之所以看到宇宙是这个样子,是因为如果它不是这样的话,我们就不会在这里去观察它。

-

如果我们仔细思考关于可能存在的宇宙的巨大迷宫,
我们就会发现大部分宇宙没有适合生命生产的条件,
哪怕任何与已知生命相近的东西,
以世人所熟悉的物理剧变来说,
这一点再清晰不过了,
If our universe didn’t conform to the rules it does,
Life as we know it would not exist,
哪怕是不那么激烈的物理变化也会干扰星球的形成,
比如,
扰乱他们作为宇宙熔炉的能力,
即合成维系生命的复杂的原子,
如碳原子,氧原子,
而碳氧原子通常是因超新星爆炸喷涌而出,
并散布在整个宇宙中的,
鉴于生命高度依赖于物理的各个细支,
如果我们现在发问,比如,
为什么自然中的各种力和粒子有我们观察到的各种特定属性组合,
一个合理的答案,
越过所有的可能性闪现出来,
这些特点各有不同,
属性也各有不同,
What’s special about the particular combination of particle and force properties we observe,
Is that clearly they allow life to form,
而生命,尤其是有智慧的生命,
是得以思考宇宙有如此属性,
的先决条件,
简单来说,
事物生来便是如此,
Because if they weren’t,
We wouldnt be here to notice,

+

如果我们仔细思考关于可能存在的宇宙的巨大迷宫,
我们就会发现大部分宇宙没有适合生命生产的条件,
哪怕任何与已知生命相近的东西。

+

以世人所熟悉的物理剧变来说,
这一点再清晰不过了,

+

If our universe didn’t conform to the rules it does,
Life as we know it would not exist。

+

哪怕是不那么激烈的物理变化也会干扰星球的形成,
比如,扰乱他们作为宇宙熔炉的能力,
即合成维系生命的复杂的原子,
如碳原子,氧原子,
而碳氧原子通常是因超新星爆炸喷涌而出并散布在整个宇宙中。

+

鉴于生命高度依赖于物理的各个细支,
如果我们现在发问,比如,
为什么自然中的各种力和粒子有我们观察到的各种特定属性组合?

+

一个合理的答案,
越过所有的可能性闪现出来,
这些特点各有不同,
属性也各有不同。

+

What’s special about the particular combination of particle and force properties we observe,
Is that clearly they allow life to form。

+

而生命,尤其是有智慧的生命,
是得以思考宇宙有如此属性的先决条件,
简单来说,事物生来便是如此。

+

Because if they weren’t,
We wouldnt be here to notice,

If we weren’t here,
There’d be no one to see。

政治和工业的缺失,
诸神危机,
短浅目光,
停止怀疑其真伪,
你的敬畏感,
你的惊奇感,
面对这一切时丝毫无损,
也许适时的,
会有人听到这段残声,
这段无主题的演讲。


diff --git a/search.xml b/search.xml index 45e96d87..0d89d3fb 100644 --- a/search.xml +++ b/search.xml @@ -952,31 +952,6 @@ TypeScript - - caml_release_runtime_system导致的死锁问题 - /2023/06/28/caml-release-runtime-system%E5%AF%BC%E8%87%B4%E7%9A%84%E6%AD%BB%E9%94%81%E9%97%AE%E9%A2%98/ - 给出一个test.ml:

-
Printf.eprintf "hello from OCaml\n%!"
- -

和test-ocaml-5.c:

-
#include <stdio.h>
#include <stdlib.h>
#include <caml/misc.h>
#include <caml/callback.h>
#include <caml/threads.h>

int
main (int argc, char *argv[])
{
fprintf (stderr, "starting up ...\n");
caml_startup (argv);
fprintf (stderr, "acquiring ...\n");
caml_acquire_runtime_system ();
fprintf (stderr, "acquired\n");
// here is where I would be calling an OCaml callback
// omitted for simplicity
caml_release_runtime_system ();
exit (0);
}
- -

然后用OCaml5的ocaml native compiler编译一下(这里我用的是ocaml-variants.5.0.0+options):
ocamlopt -g test-ocaml-5.c test.ml -o test-ocaml-5

-

运行test-ocaml-5 会出现:

-
starting up ...
hello from OCaml
acquiring ...
Fatal error: Fatal error during lock: Resource deadlock avoided

[1] 8998 IOT instruction (core dumped) ./test-ocaml-5
- -

这里我尝试了一下 4.14.0 和 4.14.1 , 都没有出现这个情况,而如果用threads编译的话:
ocamlopt -g -I +unix unix.cmxa -I +threads threads.cmxa test-ocaml-5.c test.ml -o test-ocaml-5

-

无论在5.0还是4.14.x,都会挂起。

-

出现这个问题的一个可能原因是,在test-ocaml-5.c中,我在开头调用了caml_startup(),这会让当前线程获取锁,而caml_acquire_runtime_system()会再次获取它,caml_acquire_runtime_system() 应该在caml_release_runtime_system()之后调用:

-
int
main (int argc, char *argv[])
{
fprintf (stderr, "starting up ...\n");
caml_startup (argv);
fprintf (stderr, "acquiring ...\n");
caml_release_runtime_system ();
caml_acquire_runtime_system ();
fprintf (stderr, "acquired\n");
exit (0);
}
- -

运行结果为:

-
starting up ...
hello from OCaml
acquiring ...
acquired
]]>
- - Technique - OCaml - -
WiscKey: Separating Keys from Values in SSD-conscious Storage /2023/07/21/WiscKey-Separating-Keys-from-Values-in-SSD-conscious-Storage/ @@ -1016,6 +991,31 @@ Database + + caml_release_runtime_system导致的死锁问题 + /2023/06/28/caml-release-runtime-system%E5%AF%BC%E8%87%B4%E7%9A%84%E6%AD%BB%E9%94%81%E9%97%AE%E9%A2%98/ + 给出一个test.ml:

+
Printf.eprintf "hello from OCaml\n%!"
+ +

和test-ocaml-5.c:

+
#include <stdio.h>
#include <stdlib.h>
#include <caml/misc.h>
#include <caml/callback.h>
#include <caml/threads.h>

int
main (int argc, char *argv[])
{
fprintf (stderr, "starting up ...\n");
caml_startup (argv);
fprintf (stderr, "acquiring ...\n");
caml_acquire_runtime_system ();
fprintf (stderr, "acquired\n");
// here is where I would be calling an OCaml callback
// omitted for simplicity
caml_release_runtime_system ();
exit (0);
}
+ +

然后用OCaml5的ocaml native compiler编译一下(这里我用的是ocaml-variants.5.0.0+options):
ocamlopt -g test-ocaml-5.c test.ml -o test-ocaml-5

+

运行test-ocaml-5 会出现:

+
starting up ...
hello from OCaml
acquiring ...
Fatal error: Fatal error during lock: Resource deadlock avoided

[1] 8998 IOT instruction (core dumped) ./test-ocaml-5
+ +

这里我尝试了一下 4.14.0 和 4.14.1 , 都没有出现这个情况,而如果用threads编译的话:
ocamlopt -g -I +unix unix.cmxa -I +threads threads.cmxa test-ocaml-5.c test.ml -o test-ocaml-5

+

无论在5.0还是4.14.x,都会挂起。

+

出现这个问题的一个可能原因是,在test-ocaml-5.c中,我在开头调用了caml_startup(),这会让当前线程获取锁,而caml_acquire_runtime_system()会再次获取它,caml_acquire_runtime_system() 应该在caml_release_runtime_system()之后调用:

+
int
main (int argc, char *argv[])
{
fprintf (stderr, "starting up ...\n");
caml_startup (argv);
fprintf (stderr, "acquiring ...\n");
caml_release_runtime_system ();
caml_acquire_runtime_system ();
fprintf (stderr, "acquired\n");
exit (0);
}
+ +

运行结果为:

+
starting up ...
hello from OCaml
acquiring ...
acquired
]]>
+ + Technique + OCaml + +
使用 [@poll error] 实现线程安全的数据结构 /2023/08/15/poll-error-attribute-in-OCaml/ @@ -1316,7 +1316,15 @@ 二〇二四年八月一日 /2024/08/02/%E4%BA%8C%E3%80%87%E4%BA%8C%E5%9B%9B%E5%B9%B4%E5%85%AB%E6%9C%88%E4%B8%80%E6%97%A5/ 我们之所以看到宇宙是这个样子,是因为如果它不是这样的话,我们就不会在这里去观察它。

-

如果我们仔细思考关于可能存在的宇宙的巨大迷宫,
我们就会发现大部分宇宙没有适合生命生产的条件,
哪怕任何与已知生命相近的东西,
以世人所熟悉的物理剧变来说,
这一点再清晰不过了,
If our universe didn’t conform to the rules it does,
Life as we know it would not exist,
哪怕是不那么激烈的物理变化也会干扰星球的形成,
比如,
扰乱他们作为宇宙熔炉的能力,
即合成维系生命的复杂的原子,
如碳原子,氧原子,
而碳氧原子通常是因超新星爆炸喷涌而出,
并散布在整个宇宙中的,
鉴于生命高度依赖于物理的各个细支,
如果我们现在发问,比如,
为什么自然中的各种力和粒子有我们观察到的各种特定属性组合,
一个合理的答案,
越过所有的可能性闪现出来,
这些特点各有不同,
属性也各有不同,
What’s special about the particular combination of particle and force properties we observe,
Is that clearly they allow life to form,
而生命,尤其是有智慧的生命,
是得以思考宇宙有如此属性,
的先决条件,
简单来说,
事物生来便是如此,
Because if they weren’t,
We wouldnt be here to notice,

+

如果我们仔细思考关于可能存在的宇宙的巨大迷宫,
我们就会发现大部分宇宙没有适合生命生产的条件,
哪怕任何与已知生命相近的东西。

+

以世人所熟悉的物理剧变来说,
这一点再清晰不过了,

+

If our universe didn’t conform to the rules it does,
Life as we know it would not exist。

+

哪怕是不那么激烈的物理变化也会干扰星球的形成,
比如,扰乱他们作为宇宙熔炉的能力,
即合成维系生命的复杂的原子,
如碳原子,氧原子,
而碳氧原子通常是因超新星爆炸喷涌而出并散布在整个宇宙中。

+

鉴于生命高度依赖于物理的各个细支,
如果我们现在发问,比如,
为什么自然中的各种力和粒子有我们观察到的各种特定属性组合?

+

一个合理的答案,
越过所有的可能性闪现出来,
这些特点各有不同,
属性也各有不同。

+

What’s special about the particular combination of particle and force properties we observe,
Is that clearly they allow life to form。

+

而生命,尤其是有智慧的生命,
是得以思考宇宙有如此属性的先决条件,
简单来说,事物生来便是如此。

+

Because if they weren’t,
We wouldnt be here to notice,

If we weren’t here,
There’d be no one to see。

政治和工业的缺失,
诸神危机,
短浅目光,
停止怀疑其真伪,
你的敬畏感,
你的惊奇感,
面对这一切时丝毫无损,
也许适时的,
会有人听到这段残声,
这段无主题的演讲。


-- cgit v1.2.3