CritSectionVsKernelObjectThis is a repo with the sample code for my blog post:Critical Section vs Kernel ObjectsSpinning in user-mode versus entering kernel - the cost of a SYSCALL in Windows.This POC project demonstrates performance difference between a critical section and a synchronization kernel object in Windows.It covers the following topics:IntroCritical SectionCritical Section InternalsKernel Synchronization ObjectsEntering Kernel From a User-ModeThe Cost of a SYSCALLEntering SYSCALLsyscall InstructionBeginning of The System Call HandlerKernel Stack LayoutKiSystemServiceUserKiSystemServiceStart - System Service NumberSystem Service Descriptor TablesSystem Service Number To Service FunctionService Function Input ParametersCalling The Service FunctionLeaving SYSCALLReturn From The Service FunctionProcessing User-Mode APCsSecurity Mitigations At ExitInstrumentation CallbackMore Security Mitigations At Exitsysretq InstructionSystem Exit With Meltdown MitigationsAlternative ExitKiServiceInternalZw* Kernel Functions PrologNt* Kernel FunctionsPOC To Illustrate The Performance ImpactConclusion