You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 513b28a
Browse filesBrowse the repository at this point in the historyBrowse files
0.14.1 --- a copy of the space can start a thread (#29)
Fixesmcpplibs/openkal-musl#55.
`kal_space_start` made the copy with the duplication primitive alone. This system's `fork` does more: around the primitive each part of the system library takes its locks, and in the copy each makes its state true of the new process. Without that, the copy's first thread failed with `EAGAIN`.
Measured on macOS 14.8.9, in a program that duplicated itself with the primitive and asked the copy for a thread:
| preparations | the copy's `pthread_create` |
| --- | --- |
| none | `EAGAIN` |
| the two child preparations alone | the copy was killed |
| and the thread library's locks around the primitive | 0 |
| the whole set, in the library's order, five rounds of twenty threads | 0 |
The routine `fork` itself calls (`_libSystem_atfork_*`) is not exported; the parts it calls are (dyld, malloc, libc, the thread library, and `_mach_fork_child`). They are called in the library's order, under names no C library in this ecosystem defines, so they are reachable beneath one. `port/libSystem.tbd` lists them for a link made elsewhere, and `-U` leaves them for the loader in a native link, whose development stub need not list them. Handlers a program registers with `pthread_atfork` are not run: a copy made here is not a `fork` the program asked for.
`tests/conformance_space_task.cpp` starts a context, joins it and starts one with a least stack size in a copy, three times, and reads the outcome through `kal_process_wait`.
Copy file name to clipboardExpand all lines: mcpp.toml
+26-1Lines changed: 26 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
[package]
2
2
namespace = "mcpplibs"
3
3
name = "openkal-macos"
4
-
version = "0.14.0"
4
+
version = "0.14.1"
5
5
description = "An implementation of openkal for macOS, written on the kernel's own calls. Its purpose is as much to test the specification as to be used."
6
6
license = "Apache-2.0"
7
7
@@ -70,6 +70,31 @@ flags = [
70
70
"-fno-stack-protector", "-fno-builtin"] },
71
71
]
72
72
73
+
# THE PREPARATIONS FOR A DUPLICATE ARE LEFT FOR THE LOADER TO FIND.
74
+
#
75
+
# kal_space_start calls the parts of the system library that this system's
76
+
# `fork' calls around the duplication primitive (src/space.cpp,
77
+
# mcpplibs/openkal-musl#55). They are exported, and they are not part of the
78
+
# interface the system documents, so a development stub need not list them.
79
+
# `-U' states that a name may be left for the loader to find among the images
80
+
# it has loaded, which is where it is; a name the stub does list is bound as
81
+
# usual. A link made elsewhere reads port/libSystem.tbd, which lists them. The
82
+
# flags reach every program above this package: mcpp forwards a dependency's
0 commit comments