From cb93e86f35c1960c9bce59b5e4f46fb208e76879 Mon Sep 17 00:00:00 2001 From: NicJA Date: Mon, 20 Feb 2017 02:59:03 +0000 Subject: [PATCH] cleanup. really update the scheduling data for the cpu we are running on, using the granularity value. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@53789 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/all-pc/kernel/apic_heartbeat.c | 47 ++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/arch/all-pc/kernel/apic_heartbeat.c b/arch/all-pc/kernel/apic_heartbeat.c index 28cf3bb8c3..e913f3aab5 100644 --- a/arch/all-pc/kernel/apic_heartbeat.c +++ b/arch/all-pc/kernel/apic_heartbeat.c @@ -3,7 +3,7 @@ $Id$ */ -#define DEBUG 1 +#define DEBUG 0 #include #include @@ -21,13 +21,48 @@ /* * Unlike the VBlankServer, we might not run at a fixed 60Hz. */ -AROS_INTH3(APICHeartbeatServer, struct List *, intList, intMask, custom) +void APICHeartbeatServer(struct ExecBase *SysBase, void *unused) { - AROS_INTFUNC_INIT + struct KernelBase *KernelBase = __kernelBase; + struct PlatformData *pdata = KernelBase->kb_PlatformData; + struct APICData *apicData = pdata->kb_APIC; +#if defined(__AROSEXEC_SMP__) + struct X86SchedulerPrivate *apicScheduleData; + tls_t *apicTLS; +#endif + UWORD current; - D(bug("[Kernel:APIC] %s()\n", __func__)); + if (apicData->flags & APF_TIMER) + { +#if defined(__AROSEXEC_SMP__) + apicid_t cpuNum = core_APIC_GetNumber(apicData); - return 1; + D(bug("[Kernel:APIC.%03u] %s()\n", cpuNum, __func__)); - AROS_INTFUNC_EXIT + apicTLS = apicData->cores[cpuNum].cpu_TLS; + if ((apicTLS) && ((apicScheduleData = apicTLS->ScheduleData) != NULL)) + { + if ((current = apicScheduleData->Elapsed)) + { + if ((apicScheduleData->Elapsed = (current - apicScheduleData->Granularity)) == 0) + { + __AROS_ATOMIC_OR_L(apicScheduleData->ScheduleFlags, TLSSF_Quantum); + __AROS_ATOMIC_OR_L(apicScheduleData->ScheduleFlags, TLSSF_Switch); + } + } + } +#else + D(bug("[Kernel:APIC] %s()\n", __func__)); + + current = SCHEDELAPSED_GET; + if (current) + SCHEDELAPSED_SET(--current); + + if (current == 0) + { + FLAG_SCHEDQUANTUM_SET; + FLAG_SCHEDSWITCH_SET; + } +#endif + } } -- 2.11.4.GIT