amos 2f32624d3b Batch 18 (20261026-C-hwe-codegen-18): add 100 calibrated HWE code-gen tasks; pause production for rollout
100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth
range given to batch 22), each with at least one independent
contract-edge defect and plain public docs. Claude reviewed 100/100
USABLE against current digests; no ID or source overlap with main or
batch 22. Difficulty is unmeasured.

progress.md records the wrap-up: all Codex sessions and Qwen schedulers
stopped for the user's rollout, Qwen results so far (57 HARD of 373),
and what is left on each batch branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 17:52:13 +08:00

87 lines
3.5 KiB
C++

#include "thread_signal.hpp"
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
using namespace thread_signal;
void print_thread(const std::string& command, const ThreadView& v) {
std::cout << command << ' ' << v.rc << ' ' << v.id << ' ' << v.phase << ' '
<< v.allowed << ' ' << v.wait_token << ' ' << v.reserved_units
<< ' ' << v.reason << ' ' << v.exit_code << '\n';
}
void print_pending(const std::string& command, const PendingView& v) {
std::cout << command << ' ' << v.rc << ' ' << v.signals.size();
for (auto signal : v.signals) std::cout << ' ' << signal;
std::cout << '\n';
}
void print_pool(const std::string& command, const PoolView& v) {
std::cout << command << ' ' << v.thread_limit << ' ' << v.unit_limit
<< ' ' << v.used_threads << ' ' << v.used_units << '\n';
}
int main() {
std::unique_ptr<Runtime> instances[2];
unsigned selected = 0;
std::string command;
while (std::cin >> command) {
std::uint32_t id = 0, value = 0;
if (command == "NEW" || command == "ALT") {
std::cin >> id >> value;
const unsigned index = command == "NEW" ? 0 : 1;
try {
instances[index] = std::make_unique<Runtime>(id, value);
std::cout << command << " OK\n";
} catch (const std::invalid_argument&) {
std::cout << command << " INVALID_ARGUMENT\n";
}
continue;
}
if (command == "SELECT") {
std::cin >> selected;
std::cout << "SELECT " << selected << '\n';
continue;
}
Runtime& runtime = *instances[selected];
if (command == "POOL" || command == "COPY_POOL") {
if (command == "COPY_POOL") {
auto copy = runtime.pool();
copy = {};
}
print_pool(command, runtime.pool());
continue;
}
std::cin >> id;
if (command == "THREAD" || command == "COPY_THREAD") {
if (command == "COPY_THREAD") {
auto copy = runtime.thread(id);
copy = {};
}
print_thread(command, runtime.thread(id));
} else if (command == "PENDING" || command == "COPY_PENDING") {
if (command == "COPY_PENDING") {
auto copy = runtime.pending(id);
copy.rc = 0;
copy.signals.assign(1, 31);
}
print_pending(command, runtime.pending(id));
} else if (command == "STEP") {
auto v = runtime.step(id);
std::cout << "STEP " << v.rc << ' ' << v.event << ' ' << v.signal
<< ' ' << v.wait_token << ' ' << v.exit_code << '\n';
} else if (command == "JOIN" || command == "STOP") {
auto v = command == "JOIN" ? runtime.join(id) : runtime.stop(id);
std::cout << command << ' ' << v.rc << ' ' << v.reason << ' '
<< v.exit_code << ' ' << v.released_units << '\n';
} else {
std::cin >> value;
int rc = 0;
if (command == "SPAWN") rc = runtime.spawn(id, value);
if (command == "ALLOW") rc = runtime.allow(id, value);
if (command == "DENY") rc = runtime.deny(id, value);
if (command == "POST") rc = runtime.post(id, value);
if (command == "WAIT") rc = runtime.arm_wait(id, value);
std::cout << command << ' ' << rc << '\n';
}
}
}