applying the same logic as in pevious commit here, in order to auarantee an usable...
[AROS.git] / arch / all-pc / exec / intserver_vblank.c
blob69cc5fa74319ac9c66bfa5fbd37c2378a98066af
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
7 #include <aros/debug.h>
9 #include <aros/asmcall.h>
10 #include <exec/execbase.h>
11 #include <exec/lists.h>
13 #define __AROS_KERNEL__
15 #include "exec_intern.h"
17 #include "kernel_intern.h"
19 #include "intservers.h"
21 /* VBlankServer. The same as general purpose IntServer but also counts task's quantum */
22 AROS_INTH3(VBlankServer, struct List *, intList, intMask, custom)
24 AROS_INTFUNC_INIT
26 struct KernelBase *KernelBase = __kernelBase;
27 struct PlatformData *pdata = KernelBase->kb_PlatformData;
28 struct APICData *apicData = pdata->kb_APIC;
29 #if defined(__AROSEXEC_SMP__)
30 struct X86SchedulerPrivate *apicScheduleData;
31 tls_t *apicTLS;
32 #endif
33 D(bug("[Exec:X86] %s()\n", __func__));
36 * If the APIC's dont have their own heartbeat timer,
37 * First decrease Elapsed time for current task
39 if ((!apicData) || (!(apicData->flags & APF_TIMER)))
41 #if defined(__AROSEXEC_SMP__)
42 if (!apicData)
44 #endif
45 UWORD current = SCHEDELAPSED_GET;
46 if (current)
47 SCHEDELAPSED_SET(--current);
49 if (current == 0)
51 FLAG_SCHEDQUANTUM_SET;
52 FLAG_SCHEDSWITCH_SET;
54 #if defined(__AROSEXEC_SMP__)
56 else
58 /* we can only update cpu #0 */
59 apicTLS = apicData->cores[0].cpu_TLS;
60 if ((apicTLS) && ((apicScheduleData = apicTLS->ScheduleData) != NULL))
62 if ((apicScheduleData->Elapsed) && (--apicScheduleData->Elapsed == 0))
64 __AROS_ATOMIC_OR_L(apicScheduleData->ScheduleFlags, TLSSF_Quantum);
65 __AROS_ATOMIC_OR_L(apicScheduleData->ScheduleFlags, TLSSF_Switch);
69 #endif
72 /* Chain to the generic routine */
73 return AROS_INTC3(IntServer, intList, intMask, custom);
75 AROS_INTFUNC_EXIT