replace ad hoc driver loading with a proper driver manager, new DDK, new PnP manager with device matching, asynchronous startup, resource ownership and removal, add shared PCI capability helpers, replace typed, rigid services with a proper service manager, implement proper system shutdown and restart, shutting down unloads drivers and shuts down services, add simple power button, remove heavyweight boot self-tests and SMP stress runs, add monotonic timestamps to kernel debug output, fruitless USB and PS/2 fixes, make test builds opt in.
This commit is contained in:
1 parent
c0ad63c27f
commit
d36f19509c
160 files changed
+6563
-7366
No files matched your search
@@ -0,0 +1,27 @@
|
||||
// Service restart budget: three automatic attempts in any sliding five-minute interval.
|
||||
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct INIT_RESTART_BUDGET {
|
||||
uint64_t Attempts[3];
|
||||
uint32_t Count;
|
||||
} INIT_RESTART_BUDGET;
|
||||
|
||||
static inline bool InitConsumeRestartBudget(INIT_RESTART_BUDGET* budget,
|
||||
uint64_t now, uint64_t frequency) {
|
||||
if (!budget || !frequency || budget->Count > 3u ||
|
||||
frequency > UINT64_MAX / 300u) return false;
|
||||
uint64_t window = frequency * 300u;
|
||||
uint32_t keep = 0;
|
||||
for (uint32_t i = 0; i < budget->Count; ++i) {
|
||||
uint64_t started = budget->Attempts[i];
|
||||
if (now >= started && now - started < window)
|
||||
budget->Attempts[keep++] = started;
|
||||
}
|
||||
budget->Count = keep;
|
||||
if (keep == 3u) return false;
|
||||
budget->Attempts[budget->Count++] = now;
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user