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>
127 lines
3.0 KiB
C++
127 lines
3.0 KiB
C++
#include "irq_internal.hpp"
|
|
namespace irqcycle {
|
|
void Model::Impl::enqueue(Line& line) {
|
|
View& value=line.v;
|
|
if (value.ready!=0 || value.running!=0) {
|
|
value.pending=1;
|
|
return;
|
|
}
|
|
value.ready=1;
|
|
value.ticket=next_ticket;
|
|
++next_ticket;
|
|
if (value.oneshot!=0) {
|
|
value.masked=1;
|
|
}
|
|
queue.push_back(static_cast<int>(value.id));
|
|
}
|
|
void Model::Impl::dequeue(int id) {
|
|
const auto entry=std::find(queue.begin(),queue.end(),id);
|
|
if (entry!=queue.end()) {
|
|
queue.erase(entry);
|
|
}
|
|
}
|
|
void Model::Impl::invoke_top(Line& line) {
|
|
View& value=line.v;
|
|
++value.hard;
|
|
switch (value.mode) {
|
|
case 0:
|
|
++value.none;
|
|
break;
|
|
case 1:
|
|
++value.handled;
|
|
break;
|
|
case 2:
|
|
++value.wakes;
|
|
enqueue(line);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
Result Model::arrive(long long id,long long count) {
|
|
if (!Impl::valid_id(id) || count<0 || count>32) {
|
|
return Impl::error(1);
|
|
}
|
|
Result status=impl_->accessible(id,false);
|
|
if (status.code!=0) {
|
|
return status;
|
|
}
|
|
Impl::Line& line=*impl_->find(id);
|
|
for (long long index=0;index<count;++index) {
|
|
++line.v.received;
|
|
if (line.v.masked!=0) {
|
|
++line.v.masked_arrivals;
|
|
// PENDING_LATCH
|
|
line.v.pending=1;
|
|
} else {
|
|
impl_->invoke_top(line);
|
|
}
|
|
}
|
|
++impl_->step;
|
|
return {0,count};
|
|
}
|
|
std::vector<int> Model::Impl::ordered() const {
|
|
std::vector<int> result(queue.begin(),queue.end());
|
|
std::sort(result.begin(),result.end(),[this](int left,int right) {
|
|
const View& a=find(left)->v;
|
|
const View& b=find(right)->v;
|
|
if (a.priority!=b.priority) {
|
|
return a.priority<b.priority;
|
|
}
|
|
return a.ticket<b.ticket;
|
|
});
|
|
return result;
|
|
}
|
|
std::vector<int> Model::ready_order() const {
|
|
return impl_->ordered();
|
|
}
|
|
Result Model::begin(long long id) {
|
|
Result status=impl_->accessible(id,true);
|
|
if (status.code!=0) {
|
|
return status;
|
|
}
|
|
Impl::Line& line=*impl_->find(id);
|
|
if (line.v.running!=0) {
|
|
return Impl::error(6);
|
|
}
|
|
if (line.v.ready==0) {
|
|
return Impl::error(7);
|
|
}
|
|
impl_->dequeue(static_cast<int>(id));
|
|
line.v.ready=0;
|
|
line.v.ticket=0;
|
|
line.v.running=1;
|
|
++line.v.begun;
|
|
++impl_->step;
|
|
return {0,id};
|
|
}
|
|
Result Model::next() {
|
|
const std::vector<int> order=impl_->ordered();
|
|
if (order.empty()) {
|
|
return Impl::error(8);
|
|
}
|
|
return begin(order.front());
|
|
}
|
|
Result Model::end(long long id) {
|
|
Result status=impl_->accessible(id,true);
|
|
if (status.code!=0) {
|
|
return status;
|
|
}
|
|
Impl::Line& line=*impl_->find(id);
|
|
if (line.v.running==0) {
|
|
return Impl::error(7);
|
|
}
|
|
line.v.running=0;
|
|
++line.v.ended;
|
|
line.v.masked=0;
|
|
if (line.v.pending!=0) {
|
|
--line.v.pending;
|
|
++line.v.replays;
|
|
impl_->invoke_top(line);
|
|
}
|
|
impl_->complete_if_idle(line);
|
|
++impl_->step;
|
|
return {0,id};
|
|
}
|
|
}
|