Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@ for Linux, written on the kernel's own system-call interface.

```toml
[dependencies]
openkal = "0.26.0"
openkal = "0.26.1"

[target.'cfg(os = "linux")'.dependencies]
openkal-linux = "0.27.2"
openkal-linux = "0.27.3"
```

## What 0.27.3 changes

**A start that states no preference leaves the environment as it was given**
(openkal 0.26.1, clause 7.17). A start removed every `KAL_RESOURCES` variable the
caller gave and wrote this process's own preference where it was not balanced, so
a program of the environment that is not an openkal program --- a compiler, a
shell --- received a variable its caller had not written, and a caller that
composed an environment could not start a program with the default. The variable
is now written only for a start that states a preference; a caller that passes its
own environment on passes its preference with it. The suite of 0.26.1 observes
both starts.

## What 0.27.2 fixes

**The riscv64 record of a signal's action is 32 bytes.** The kernel's record is
Expand Down
2 changes: 1 addition & 1 deletion mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
namespace = "mcpplibs"
name = "openkal-linux"
version = "0.27.2"
version = "0.27.3"
description = "The reference implementation of openkal for Linux, written on the kernel's own system-call interface so that it can be placed beneath a C library as well as above one."
license = "Apache-2.0"

Expand Down
23 changes: 11 additions & 12 deletions src/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ int child_outcome(okl_long pid, bool block, int* status, int* terminated, bool&
void job_forget(okl_long unit);
bool child_memory(okl_long pid, bool ended, okl_u64& now, okl_u64& peak);
bool child_cpu(okl_long pid, okl_u64& ns);
int resource_preference();
bool child_faults(okl_long pid, okl_u64& minor, okl_u64& major);
}

Expand Down Expand Up @@ -44,7 +43,11 @@ bool names_preopens(const char* s, kal_uintptr n) {
// THE TWO VARIABLES 0.23 WRITES BESIDE IT: what each grant carries
// (`KAL_GRANT_RIGHTS', read in fs.cpp) and the started program's resource
// preference (`KAL_RESOURCES', read in env.cpp). A value of either the caller
// supplied is left out where this start writes its own.
// supplied is left out where this start writes its own. A start that states no
// preference writes none and leaves the caller's variable where it is: the
// preference is inherited through the environment the caller gives
// (openkal 0.26.1, clause 7.17), and a program that is not an openkal program
// receives exactly that environment.
constexpr char kRights[] = "KAL_GRANT_RIGHTS=";
constexpr okl_uptr kRightsLen = sizeof kRights - 1;
constexpr char kResources[] = "KAL_RESOURCES=";
Expand All @@ -65,7 +68,8 @@ struct conveyance {
// The descriptors of the records, placed after the grants.
okl_long record_src[16];
kal_uintptr records = 0;
// KAL_RESOURCES's value, or empty to leave what the caller's environment holds.
// KAL_RESOURCES's value for a start that states a preference; null leaves
// the environment the caller gave as it was.
const char* resources = nullptr;
};

Expand Down Expand Up @@ -180,7 +184,7 @@ struct vector {
const kal_preopen* grants, kal_uintptr g, const conveyance& c) {
auto left_out = [&](const char* s, kal_uintptr l) {
return names_preopens(s, l) || starts_with(s, l, kRights, kRightsLen)
|| starts_with(s, l, kResources, kResourcesLen);
|| (c.resources && starts_with(s, l, kResources, kResourcesLen));
};
kal_uintptr kept = 0;
okl_uptr total = 0;
Expand Down Expand Up @@ -1009,14 +1013,9 @@ int kal_process_spawn(const kal_spawn* how,
okl::copy(carry.rights + carry.rights_len, prefix, plen); carry.rights_len += plen;
carry.any_rights = true;
}
{
const int own = okl::resource_preference();
const int asked = preference == KAL_SPAWN_RESOURCES_PERFORMANCE ? 1
: preference == KAL_SPAWN_RESOURCES_ECONOMY ? 2
: preference == KAL_SPAWN_RESOURCES_BALANCED ? 0 : own;
carry.resources = asked == 1 ? "performance" : asked == 2 ? "economy"
: preference != 0 ? "balanced" : nullptr;
}
carry.resources = preference == KAL_SPAWN_RESOURCES_PERFORMANCE ? "performance"
: preference == KAL_SPAWN_RESOURCES_ECONOMY ? "economy"
: preference == KAL_SPAWN_RESOURCES_BALANCED ? "balanced" : nullptr;

vector args, envs;
if (!args.build(argv, argv_lens, argc)) return kal_err_no_memory;
Expand Down
Loading