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

112 lines
3.7 KiB
C++

#include "irq_internal.hpp"
namespace irqcycle {
void Model::Impl::top(State& s,int id) {
const Registration& reg=s.registrations.at(id);
Counters& c=s.counters.at(id);
++c.hard;
if (reg.mode==0) { ++c.none; return; }
if (reg.mode==1) { ++c.handled; return; }
++c.wakes;
if (s.activations.count(id)) {
s.pending.insert(id);
return;
}
const auto ticket=s.next_ticket++;
s.activations.emplace(id,Activation{false,ticket});
s.buckets[reg.priority].emplace(ticket,id);
}
void Model::Impl::complete(State& s,int id) {
Registration& reg=s.registrations.at(id);
if (reg.state==2 && !s.activations.count(id) && !s.pending.count(id)) {
reg.state=3;
s.tokens.at(reg.token)=true;
}
}
Result Model::Impl::reduce(State& s,const Event& e) {
if (e.kind==Next) {
for (const auto& bucket:s.buckets) {
if (!bucket.empty()) return reduce(s,{Begin,bucket.begin()->second});
}
return {8,0};
}
if (!valid_id(e.id)) return {1,0};
const int id=static_cast<int>(e.id);
if (e.kind==Open) {
if (e.a<0 || e.a>1 || e.b<0 || e.b>7 || e.c<0 || e.c>2) return {1,0};
auto previous=s.registrations.find(id);
if (previous!=s.registrations.end() && previous->second.state!=3) return {2,0};
const auto gen=previous==s.registrations.end()?1:previous->second.generation+1;
Registration reg;
reg.generation=gen; reg.oneshot=e.a; reg.priority=e.b; reg.mode=e.c;
s.registrations[id]=reg;
s.counters[id]=Counters{};
++s.step;
return {0,static_cast<long long>(gen)};
}
if (e.kind==Mode && (e.a<0 || e.a>2)) return {1,0};
if (e.kind==Arrive && (e.a<0 || e.a>32)) return {1,0};
if (e.kind==Free) {
auto entry=s.registrations.find(id);
if (entry==s.registrations.end()) return {3,0};
Registration& reg=entry->second;
if (reg.state!=1) return {0,static_cast<long long>(reg.token)};
reg.state=2; reg.token=s.next_token++;
s.tokens.emplace(reg.token,false);
complete(s,id);
++s.step;
return {0,static_cast<long long>(reg.token)};
}
Result allowed=access(s,id,e.kind==Begin || e.kind==End);
if (allowed.code) return allowed;
Registration& reg=s.registrations.at(id);
Counters& c=s.counters.at(id);
switch (e.kind) {
case Mode:
reg.mode=e.a;
++s.step;
return {};
case Arrive:
for (long long n=0;n<e.a;++n) {
++c.received;
if (reg.oneshot && s.activations.count(id)) {
++c.masked_arrivals;
s.pending.insert(id);
} else {
top(s,id);
}
}
++s.step;
return {0,e.a};
case Begin: {
auto work=s.activations.find(id);
if (work==s.activations.end()) return {7,0};
if (work->second.executing) return {6,0};
s.buckets[reg.priority].erase(work->second.ticket);
work->second.executing=true;
work->second.ticket=0;
++c.begun; ++s.step;
return {0,id};
}
case End: {
auto work=s.activations.find(id);
if (work==s.activations.end() || !work->second.executing) return {7,0};
s.activations.erase(work);
++c.ended;
if (s.pending.erase(id)) { ++c.replays; top(s,id); }
complete(s,id);
++s.step;
return {0,id};
}
default:
return {7,0};
}
}
std::vector<int> Model::ready_order() const {
std::vector<int> result;
for (const auto& bucket:impl_->state.buckets) {
for (const auto& work:bucket) result.push_back(work.second);
}
return result;
}
}