mirror of https://github.com/rusefi/rusefi.git
Revert "Allow scheduling_s to come from a pool (#4841)"
This reverts commit 5250b177
This commit is contained in:
parent
8f6f7819a4
commit
8c9b17485e
|
@ -365,7 +365,6 @@ float mapFast
|
|||
uint16_t autoscale rawMaf2;;"V",{1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 5, 3
|
||||
uint16_t autoscale mafMeasured2;@@GAUGE_NAME_AIR_FLOW_MEASURED_2@@;"kg/h",{1/@@PACK_MULT_MASS_FLOW@@}, 0, 0, 0, 1
|
||||
|
||||
uint16_t schedulingUsedCount;;"",1,0,0,0,0
|
||||
uint16_t autoscale vehicleSpeedKph;@@GAUGE_NAME_VVS@@;"kph",{1/@@PACK_MULT_VSS@@}, 0, 0, 0, 2
|
||||
|
||||
uint16_t autoscale Gego;;"%",0.01,0,50,150,2
|
||||
|
|
|
@ -57,6 +57,9 @@ bool isRunningBenchTest(void) {
|
|||
return isRunningBench;
|
||||
}
|
||||
|
||||
static scheduling_s benchSchedStart;
|
||||
static scheduling_s benchSchedEnd;
|
||||
|
||||
static void benchOn(OutputPin* output) {
|
||||
output->setValue(true);
|
||||
}
|
||||
|
@ -102,8 +105,8 @@ static void runBench(brain_pin_e brainPin, OutputPin *output, float startDelayMs
|
|||
efitick_t endTime = startTime + US2NT(onTimeUs);
|
||||
|
||||
// Schedule both events
|
||||
engine->executor.scheduleByTimestampNt("bstart", nullptr, startTime, {benchOn, output});
|
||||
engine->executor.scheduleByTimestampNt("bend", nullptr, endTime, {benchOff, output});
|
||||
engine->executor.scheduleByTimestampNt("bstart", &benchSchedStart, startTime, {benchOn, output});
|
||||
engine->executor.scheduleByTimestampNt("bend", &benchSchedEnd, endTime, {benchOff, output});
|
||||
|
||||
// Wait one full cycle time for the event + delay to happen
|
||||
chThdSleepMicroseconds(onTimeUs + offTimeUs);
|
||||
|
|
|
@ -38,6 +38,9 @@ public:
|
|||
|
||||
float injectionStartAngle = 0;
|
||||
|
||||
scheduling_s signalTimerUp;
|
||||
scheduling_s endOfInjectionEvent;
|
||||
|
||||
/**
|
||||
* we need atomic flag so that we do not schedule a new pair of up/down before previous down was executed.
|
||||
*
|
||||
|
|
|
@ -155,11 +155,13 @@ static void startKnockSampling(Engine* engine) {
|
|||
onStartKnockSampling(cylinderNumberCopy, samplingSeconds, channel);
|
||||
}
|
||||
|
||||
static scheduling_s startSampling;
|
||||
|
||||
void Engine::onSparkFireKnockSense(uint8_t cylinderNumber, efitick_t nowNt) {
|
||||
cylinderNumberCopy = cylinderNumber;
|
||||
|
||||
#if EFI_HIP_9011 || EFI_SOFTWARE_KNOCK
|
||||
scheduleByAngle(nullptr, nowNt,
|
||||
scheduleByAngle(&startSampling, nowNt,
|
||||
/*angle*/engineConfiguration->knockDetectionWindowStart, { startKnockSampling, engine });
|
||||
#else
|
||||
UNUSED(nowNt);
|
||||
|
|
|
@ -155,7 +155,7 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase
|
|||
}
|
||||
#endif /*EFI_PRINTF_FUEL_DETAILS */
|
||||
|
||||
if (isScheduled) {
|
||||
if (isScheduled) {
|
||||
#if EFI_PRINTF_FUEL_DETAILS
|
||||
if (printFuelDebug) {
|
||||
InjectorOutputPin *output = outputs[0];
|
||||
|
@ -183,9 +183,9 @@ if (isScheduled) {
|
|||
angleFromNow += getEngineState()->engineCycle;
|
||||
}
|
||||
|
||||
efitick_t startTime = scheduleByAngle(nullptr, nowNt, angleFromNow, startAction);
|
||||
efitick_t startTime = scheduleByAngle(&signalTimerUp, nowNt, angleFromNow, startAction);
|
||||
efitick_t turnOffTime = startTime + US2NT((int)durationUs);
|
||||
getExecutorInterface()->scheduleByTimestampNt("inj", nullptr, turnOffTime, endAction);
|
||||
getExecutorInterface()->scheduleByTimestampNt("inj", &endOfInjectionEvent, turnOffTime, endAction);
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
printf("scheduling injection angle=%.2f/delay=%.2f injectionDuration=%.2f\r\n", angleFromNow, NT2US(startTime - nowNt), injectionDuration);
|
||||
|
|
|
@ -60,7 +60,7 @@ void PrimeController::onIgnitionStateChanged(bool ignitionOn) {
|
|||
auto primeDelayMs = engineConfiguration->primingDelay * 1000;
|
||||
|
||||
auto startTime = getTimeNowNt() + MS2NT(primeDelayMs);
|
||||
getExecutorInterface()->scheduleByTimestampNt("prime", nullptr, startTime, { PrimeController::onPrimeStartAdapter, this });
|
||||
getExecutorInterface()->scheduleByTimestampNt("prime", &m_start, startTime, { PrimeController::onPrimeStartAdapter, this });
|
||||
} else {
|
||||
efiPrintf("Skipped priming pulse since ignSwitchCounter = %d", ignSwitchCounter);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void PrimeController::onPrimeStart() {
|
|||
// Open all injectors, schedule closing later
|
||||
m_isPriming = true;
|
||||
startSimultaneousInjection();
|
||||
getExecutorInterface()->scheduleByTimestampNt("prime", nullptr, endTime, { onPrimeEndAdapter, this });
|
||||
getExecutorInterface()->scheduleByTimestampNt("prime", &m_end, endTime, { onPrimeEndAdapter, this });
|
||||
}
|
||||
|
||||
void PrimeController::onPrimeEnd() {
|
||||
|
|
|
@ -24,6 +24,9 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
scheduling_s m_start;
|
||||
scheduling_s m_end;
|
||||
|
||||
bool m_isPriming = false;
|
||||
|
||||
static void onPrimeStartAdapter(PrimeController* instance) {
|
||||
|
|
|
@ -21,40 +21,6 @@ extern int timeNowUs;
|
|||
extern bool verboseMode;
|
||||
#endif /* EFI_UNIT_TEST */
|
||||
|
||||
EventQueue::EventQueue(efitick_t lateDelay)
|
||||
: lateDelay(lateDelay)
|
||||
{
|
||||
for (size_t i = 0; i < efi::size(m_pool); i++) {
|
||||
tryReturnScheduling(&m_pool[i]);
|
||||
}
|
||||
}
|
||||
|
||||
scheduling_s* EventQueue::getFreeScheduling() {
|
||||
auto retVal = m_freelist;
|
||||
|
||||
if (retVal) {
|
||||
m_freelist = retVal->nextScheduling_s;
|
||||
retVal->nextScheduling_s = nullptr;
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
getTunerStudioOutputChannels()->schedulingUsedCount++;
|
||||
#endif
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void EventQueue::tryReturnScheduling(scheduling_s* sched) {
|
||||
// Only return this scheduling to the free list if it's from the correct pool
|
||||
if (sched >= &m_pool[0] && sched <= &m_pool[efi::size(m_pool) - 1]) {
|
||||
sched->nextScheduling_s = m_freelist;
|
||||
m_freelist = sched;
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
getTunerStudioOutputChannels()->schedulingUsedCount--;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if inserted into the head of the list
|
||||
|
@ -62,17 +28,6 @@ void EventQueue::tryReturnScheduling(scheduling_s* sched) {
|
|||
bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeX, action_s action) {
|
||||
ScopePerf perf(PE::EventQueueInsertTask);
|
||||
|
||||
if (!scheduling) {
|
||||
scheduling = getFreeScheduling();
|
||||
|
||||
// If still null, the free list is empty and all schedulings in the pool have been expended.
|
||||
if (!scheduling) {
|
||||
// TODO: should we warn or error here?
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
assertListIsSorted();
|
||||
#endif /* EFI_UNIT_TEST */
|
||||
|
@ -255,9 +210,6 @@ bool EventQueue::executeOne(efitick_t now) {
|
|||
auto action = current->action;
|
||||
current->action = {};
|
||||
|
||||
tryReturnScheduling(current);
|
||||
current = nullptr;
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
printf("QUEUE: execute current=%d param=%d\r\n", (uintptr_t)current, (uintptr_t)action.getArgument());
|
||||
#endif
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
// See comment in EventQueue::executeAll for info about lateDelay - it sets the
|
||||
// time gap between events for which we will wait instead of rescheduling the next
|
||||
// event in a group of events near one another.
|
||||
explicit EventQueue(efitick_t lateDelay = 0);
|
||||
EventQueue(efitick_t lateDelay = 0) : lateDelay(lateDelay) {}
|
||||
|
||||
/**
|
||||
* O(size) - linear search in sorted linked list
|
||||
|
@ -61,17 +61,11 @@ public:
|
|||
scheduling_s *getElementAtIndexForUnitText(int index);
|
||||
scheduling_s * getHead();
|
||||
void assertListIsSorted() const;
|
||||
|
||||
scheduling_s* getFreeScheduling();
|
||||
void tryReturnScheduling(scheduling_s* sched);
|
||||
private:
|
||||
/**
|
||||
* this list is sorted
|
||||
*/
|
||||
scheduling_s *head = nullptr;
|
||||
const efitick_t lateDelay;
|
||||
|
||||
scheduling_s* m_freelist = nullptr;
|
||||
scheduling_s m_pool[64];
|
||||
};
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ TEST(injectionScheduling, InjectionIsScheduled) {
|
|||
// rising edge 5 degrees from now
|
||||
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
|
||||
efitick_t startTime = nowNt + nt5deg;
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, _));
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.signalTimerUp, startTime, _));
|
||||
// falling edge 20ms later
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime + MS2NT(20), _));
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.endOfInjectionEvent, startTime + MS2NT(20), _));
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,9 +73,9 @@ TEST(injectionScheduling, InjectionIsScheduledBeforeWraparound) {
|
|||
// rising edge 5 degrees from now
|
||||
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
|
||||
efitick_t startTime = nowNt + nt5deg;
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, _));
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.signalTimerUp, startTime, _));
|
||||
// falling edge 20ms later
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime + MS2NT(20), _));
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.endOfInjectionEvent, startTime + MS2NT(20), _));
|
||||
}
|
||||
|
||||
// Event scheduled at 715 degrees
|
||||
|
@ -112,9 +112,9 @@ TEST(injectionScheduling, InjectionIsScheduledAfterWraparound) {
|
|||
// rising edge 15 degrees from now
|
||||
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 15);
|
||||
efitick_t startTime = nowNt + nt5deg;
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, _));
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.signalTimerUp, startTime, _));
|
||||
// falling edge 20ms later
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime + MS2NT(20), _));
|
||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.endOfInjectionEvent, startTime + MS2NT(20), _));
|
||||
}
|
||||
|
||||
// Event scheduled at 5 degrees
|
||||
|
|
Loading…
Reference in New Issue