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>
80 lines
2.1 KiB
C++
80 lines
2.1 KiB
C++
#ifndef MASK_WRITE_INTERLOCK_HPP
|
|
#define MASK_WRITE_INTERLOCK_HPP
|
|
#include <array>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <iosfwd>
|
|
namespace maskwrite {
|
|
using Number = std::int64_t;
|
|
enum Status {
|
|
OK = 0,
|
|
RANGE = 1,
|
|
BUSY = 2,
|
|
OWNER = 3,
|
|
PHASE = 4,
|
|
FULL = 5,
|
|
EMPTY = 6
|
|
};
|
|
enum Phase {
|
|
IDLE = 0,
|
|
BUILD = 1,
|
|
CAPTURED = 2
|
|
};
|
|
enum Kind {
|
|
SET = 0,
|
|
CLEAR = 1,
|
|
REPLACE = 2
|
|
};
|
|
struct Operation {
|
|
Number reg;
|
|
Number kind;
|
|
std::uint32_t mask;
|
|
std::uint32_t value;
|
|
};
|
|
struct State {
|
|
Number owner;
|
|
Number phase;
|
|
Number count;
|
|
std::uint64_t generation;
|
|
};
|
|
class Interlock {
|
|
public:
|
|
Interlock();
|
|
Status reset();
|
|
Status load(Number reg, Number value);
|
|
Status begin(Number actor);
|
|
Status stage(Number actor, Number reg, Number kind,
|
|
Number mask, Number value);
|
|
Status capture(Number actor);
|
|
Status commit(Number actor);
|
|
Status abort(Number actor);
|
|
Status word(Number reg, std::uint32_t& result) const;
|
|
Status prepared(Number actor, Number reg, std::uint32_t& result) const;
|
|
Status changed(Number actor, Number reg, std::uint32_t& result) const;
|
|
Status operation(Number index, Operation& result) const;
|
|
State state() const;
|
|
private:
|
|
static constexpr std::size_t RegisterCount = 4;
|
|
static constexpr std::size_t QueueLimit = 8;
|
|
std::array<std::uint32_t, RegisterCount> words_;
|
|
std::array<std::uint32_t, RegisterCount> sampled_;
|
|
std::array<std::uint32_t, RegisterCount> pending_;
|
|
std::array<bool, RegisterCount> touched_;
|
|
std::array<Operation, QueueLimit> queue_;
|
|
std::array<std::array<std::array<bool, 2>, 32>, RegisterCount> functions_;
|
|
Number owner_;
|
|
Phase phase_;
|
|
std::size_t count_;
|
|
std::uint64_t generation_;
|
|
static bool actor_ok(Number actor);
|
|
static bool reg_ok(Number reg);
|
|
static bool kind_ok(Number kind);
|
|
static bool word_ok(Number value);
|
|
Status require_owner(Number actor) const;
|
|
void clear_transaction();
|
|
void compose(const Operation& operation);
|
|
};
|
|
int run_console(std::istream& input, std::ostream& output);
|
|
}
|
|
#endif
|