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
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,22 @@ for Linux, written on the kernel's own system-call interface.
openkal = "0.25.0"

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

## What 0.26.3 corrects

**The processor time on i386.** The program's processor time and the monotonic
clock read for an observation were read from the sixty-four bit `clock_gettime`
into records of two words, so the seconds were taken as the fraction and the
fraction was lost; both read `okl::ktimespec`, the record that call writes.
`tests/word32/runs.cpp` measures the processor time of 50 ms of work.

**The specification by its minor version.** The manifest declares `openkal =
"^0.25.0"`: an implementation written against a patch release conforms to every
later patch of that minor version (openkal clause 8), and a consumer that names
one resolves with it.

## What 0.26.2 adds

**i386** (openkal 0.25.1, clause 5.5). The kernel's i386 gate (`int $0x80`, the sixth
Expand Down
5 changes: 3 additions & 2 deletions mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
namespace = "mcpplibs"
name = "openkal-linux"
version = "0.26.2"
version = "0.26.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 Expand Up @@ -67,7 +67,8 @@ provides-interfaces = [
]

[dependencies]
openkal = "0.25.0"
# Every patch release of the specification's minor version (openkal clause 8).
openkal = "^0.25.0"

# The package contributes definitions and no modules. The interface it
# implements is declared by the specification package, which this package
Expand Down
4 changes: 2 additions & 2 deletions src/observe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ struct ring {
ring g_ring;

okl_u64 monotonic() {
struct { okl_long s, ns; } t{};
okl::ktimespec t{}; // the time64 record on i386 (sys.h)
okl::sys(okl::nr_clock_gettime, 1 /* CLOCK_MONOTONIC */, reinterpret_cast<okl_long>(&t));
return static_cast<okl_u64>(t.s) * 1000000000ull + static_cast<okl_u64>(t.ns);
return static_cast<okl_u64>(t.sec) * 1000000000ull + static_cast<okl_u64>(t.nsec);
}

void sample(void* uc) {
Expand Down
2 changes: 1 addition & 1 deletion src/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ okl_u64 ticks_to_ns(okl_u64 t) {
bool cpu_ns(okl_long pid, bool self, okl_u64& out) {
const okl_long clock = self ? 2 /* CLOCK_PROCESS_CPUTIME_ID */
: static_cast<okl_long>(static_cast<int>((~static_cast<unsigned>(pid)) << 3) | 2);
struct { okl_long sec, nsec; } ts{};
okl::ktimespec ts{}; // the time64 record on i386 (sys.h)
const okl_long r = okl::sys(okl::nr_clock_gettime, clock, reinterpret_cast<okl_long>(&ts));
if (!okl::failed(r)) {
out = static_cast<okl_u64>(ts.sec) * 1000000000ull + static_cast<okl_u64>(ts.nsec);
Expand Down
13 changes: 13 additions & 0 deletions tests/word32/runs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <openkal/task.h>
#include <openkal/time.h>
#include <openkal/abort.h>
#include <openkal/process.h>

static int failures = 0;
static void say(const char* s) { kal_uintptr n = 0; while (s[n]) ++n; kal_stream_write(kal_stdout(), s, n); }
Expand Down Expand Up @@ -52,6 +53,18 @@ extern "C" int main(int, char**, char**) {
const kal_duration before = kal_time_monotonic();
kal_time_sleep(20u * 1000u * 1000u);
check(kal_time_monotonic() - before >= 20u * 1000u * 1000u, "a sleep of 20 ms lasts at least that");
// The processor time is read through the sixty-four bit clock as well: worked for about
// 50 ms, it is more than 10 ms and less than the time since the program started.
const kal_duration spin = kal_time_monotonic();
volatile kal_u64 sink = 0;
while (kal_time_monotonic() - spin < 50u * 1000u * 1000u) sink = sink + 1;
kal_process me{};
kal_program_info pi{}; pi.self_size = sizeof pi;
check(kal_process_self(&me) == kal_ok && kal_process_info(me, KAL_PINFO_CPU, &pi) == kal_ok
&& (pi.present & KAL_PINFO_CPU) && pi.cpu_ns > 10u * 1000u * 1000u
&& pi.cpu_ns < kal_time_monotonic() - before + 1000u * 1000u * 1000u,
"the processor time counts the work done");
kal_process_close(me);
say(failures ? "FAILED\n" : "all held\n");
return failures;
}
Expand Down
Loading