Windows OS quantum vs. SQL OS QuantumSQL Server 2012 indirect checkpointOnce more about SQL Server virtual accountsSQL Server “Max Worker Threads” SettingCorrect way to stop SQL Server (through automation)Unable To Log In Through Windows AuthenticationHow can we have IIS talk to SQL Server with TLS1.0 disabled?Much slower SQL application performance after upgrading from Windows Server 2008 R2 to Windows Server 2012 R2Non-yielding Scheduler Error with dump caused by heavy queries on SQL 2016SQL Server Service AccountsSQL Server Processor affinity with trace flag 8002 ON

Cryptography and elliptic curves

Company threw a surprise party for the CEO, 3 weeks later management says we have to pay for it, do I have to?

Is there a need for better software for writers?

What does formal training in a field mean?

What does this quote in Small Gods refer to?

Why does it take longer to fly from London to Xi'an than to Beijing

Why are low spin tetrahedral complexes so rare?

Why do Thanos' punches not kill Captain America or at least cause vital wounds?

Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019

How to get the IP of a user who executed a command?

Improving Sati-Sampajañña (situative wisdom)

Windows OS quantum vs. SQL OS Quantum

Extending Kan fibrations, without using minimal fibrations

How to find the tex encoding of specific fonts?

How to slow yourself down (for playing nice with others)

Translation of the latin word 'sit' in Thomas Aquinas' works

Is it a good idea to copy a trader when investing?

How can I avoid subordinates and coworkers leaving work until the last minute, then having no time for revisions?

Intersecting with the x-axis / intersecting the x-axis

Is ‘despite that’ right?

Exception propagation: When to catch exceptions?

How to make a language evolve quickly?

Passport stamps art, can it be done?

What food production methods would allow a metropolis like New York to become self sufficient



Windows OS quantum vs. SQL OS Quantum


SQL Server 2012 indirect checkpointOnce more about SQL Server virtual accountsSQL Server “Max Worker Threads” SettingCorrect way to stop SQL Server (through automation)Unable To Log In Through Windows AuthenticationHow can we have IIS talk to SQL Server with TLS1.0 disabled?Much slower SQL application performance after upgrading from Windows Server 2008 R2 to Windows Server 2012 R2Non-yielding Scheduler Error with dump caused by heavy queries on SQL 2016SQL Server Service AccountsSQL Server Processor affinity with trace flag 8002 ON






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








11















Simple question:



How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)?




Deep Dive



In the next couple of sections I'll write up what I have found so far regarding the OS quantum and how the duration of a quantum can be calculated. The duration of an OS "quantum" is based on "ticks" and the duration of the "tick" itself is based on the "clock interval" which is normally 15.625000 ms. But let me elaborate a bit...



Tick



In the Blog article Know Thy Tick the author Jim explains the basics of clock intervals (aka "ticks") and what they are for.




When I read something like “the clock interval… for most x86 multiprocessors is about 15 milliseconds” I’m compelled to determine the value of my clock, or “tick”, interval. Fortunately, the book I read this quote in, Windows Internals Fourth Edition provides a reference for helping me with my affliction.
...
The author, Mark Russinovich, of the aforementioned book has graciously made the utility ClockRes available on his web site. Running this utility, I was able to determine that the clock interval on my x86 multiprocessor PC is 15.625000 ms. Interesting, but my curious mind wants to know more.




Quantum



The author of the article goes on to explain in his second article that...




Of course the real reason why the tick interval is important is that it affects thread scheduling. The Windows scheduler gives each thread a “quantum” of time to execute before allowing another task, at the same priority level, to run. The quantum that the scheduler assigns to a thread is a multiple of the tick interval. The specific quantum value chosen for a specific thread is bit beyond where I want to go with this article.




Ok, so I know what a quantum is, but not how long a quantum will run.




For now, let’s just examine the default quantum value for a foreground thread in XPe. In this case the Windows scheduler assigns a quantum of 18 or 6 tick intervals. (Yes, to convert quantum to tick intervals, one must divide by 3. ..., but the reason for the multiple is to allow the scheduler the ability to “charge” a thread for doing an operation which causes it to suspend.)




We now know that a clock interval (tick) should be around 15.625000 ms and on a Windows Desktop OS where the default quantum is 18 that this will result in 6 ticks or 93.750000 ms (18 / 3 * 15.625000 ms).



On a Windows Server OS the default quantum is different. The "Processor scheduling" setting is set to "Background Services"



This setting can be found via "System Settings | Advanced (tab) | Performance (section) | Settings ..." which will open "Perofrmance Options | Advanced (tab) | Processor scheduling"



The default quantum settings are then 36 (Background) to 36 (Foreground). The quantum is larger and hence longer. This is double the amount of the 93.750000 ms of the 18 (6 tick) quantum foreground setting on a Windows Desktop OS, which on a server OS set up for Background Services is around 187.500000 ms.



Observation / Explanation



When you change the setting from "Background services" to "Applicaitons" on either a server or desktop, then the HKLMSYSTEM CurrentControlSet Control PriorityControl Win32PrioritySeparation key in the registry is changed from 0x18 to 0x02. What is the default quantum value for 0x02? This can be found in a comment:




The value 0x02 implies that the "Short vs. Long" and "Variable vs. Fixed" fields are the default for the OS.



The default for these fields for XPe & XP Pro is: Short & Variable which is the same as having the following bits additional bits set: 0x24.



OR'ing this value in with 0x02 gives you 0x26, which you will find in the table in the article.




Reference: Comment to "Master Your Quantum" (MSDN Blogs)



The table explaining the quantum settings from the same article:



Win32PrioritySeparation Foreground Background
0x28, 0x29, 0x2A 18 18
0x18, 0x19, 0x1A 36 36
0x24 6 6
0x25, 0x14 12 6
0x26 18 6
0x15 24 6
0x16 36 6


Short Summary of OS Quantum



Based on the above information and article quotes, we know that a quantum is not a fixed size, but rather derived from an OS setting in the System Properties. A quantum varies depending on the Win32PrioritySeparation setting in the registry which normally corresponds to one of the setting in the "System Properties" (either "Background services" or "Applications").



A quantum at OS level is



  • for the "Applications" setting

    • 18 (which is 6 ticks) for foreground applications (93.75 ms)

    • 6 (which is 2 ticks) for background applications (31.25 ms)


  • for the "Background Services" setting

    • 36 (which is 18 ticks) for foreground applications (187.5 ms)

    • 36 (which is 18 ticks) for background applications (187.5 ms)


So now we know that an OS quantum on a Windows Server setup to be optimised for Background Services is ...



36 / 3 * 15.625000 ms = 187.5 ms


My Conundrum



The Server OS Quantum regulates how much time the SQL Server Service is granted to execute "tasks". The SQL Server OS Quantum is defined as 4 ms. If I divide the 187.5 ms by 4 ms then I am left with 3.5 ms.



And we haven't even started the discussion of when the Clock Interval is set to something other than the default of 15.625000 ms....



Simple Question



How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)?










share|improve this question






















  • How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)? It's not and SQL Server doesn't use preemptive scheduling. Work items are expected to hit yield points and if they don't, you get things such as NONYIELDING schedulers. There is no parity.

    – Sean Gallardy
    7 hours ago

















11















Simple question:



How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)?




Deep Dive



In the next couple of sections I'll write up what I have found so far regarding the OS quantum and how the duration of a quantum can be calculated. The duration of an OS "quantum" is based on "ticks" and the duration of the "tick" itself is based on the "clock interval" which is normally 15.625000 ms. But let me elaborate a bit...



Tick



In the Blog article Know Thy Tick the author Jim explains the basics of clock intervals (aka "ticks") and what they are for.




When I read something like “the clock interval… for most x86 multiprocessors is about 15 milliseconds” I’m compelled to determine the value of my clock, or “tick”, interval. Fortunately, the book I read this quote in, Windows Internals Fourth Edition provides a reference for helping me with my affliction.
...
The author, Mark Russinovich, of the aforementioned book has graciously made the utility ClockRes available on his web site. Running this utility, I was able to determine that the clock interval on my x86 multiprocessor PC is 15.625000 ms. Interesting, but my curious mind wants to know more.




Quantum



The author of the article goes on to explain in his second article that...




Of course the real reason why the tick interval is important is that it affects thread scheduling. The Windows scheduler gives each thread a “quantum” of time to execute before allowing another task, at the same priority level, to run. The quantum that the scheduler assigns to a thread is a multiple of the tick interval. The specific quantum value chosen for a specific thread is bit beyond where I want to go with this article.




Ok, so I know what a quantum is, but not how long a quantum will run.




For now, let’s just examine the default quantum value for a foreground thread in XPe. In this case the Windows scheduler assigns a quantum of 18 or 6 tick intervals. (Yes, to convert quantum to tick intervals, one must divide by 3. ..., but the reason for the multiple is to allow the scheduler the ability to “charge” a thread for doing an operation which causes it to suspend.)




We now know that a clock interval (tick) should be around 15.625000 ms and on a Windows Desktop OS where the default quantum is 18 that this will result in 6 ticks or 93.750000 ms (18 / 3 * 15.625000 ms).



On a Windows Server OS the default quantum is different. The "Processor scheduling" setting is set to "Background Services"



This setting can be found via "System Settings | Advanced (tab) | Performance (section) | Settings ..." which will open "Perofrmance Options | Advanced (tab) | Processor scheduling"



The default quantum settings are then 36 (Background) to 36 (Foreground). The quantum is larger and hence longer. This is double the amount of the 93.750000 ms of the 18 (6 tick) quantum foreground setting on a Windows Desktop OS, which on a server OS set up for Background Services is around 187.500000 ms.



Observation / Explanation



When you change the setting from "Background services" to "Applicaitons" on either a server or desktop, then the HKLMSYSTEM CurrentControlSet Control PriorityControl Win32PrioritySeparation key in the registry is changed from 0x18 to 0x02. What is the default quantum value for 0x02? This can be found in a comment:




The value 0x02 implies that the "Short vs. Long" and "Variable vs. Fixed" fields are the default for the OS.



The default for these fields for XPe & XP Pro is: Short & Variable which is the same as having the following bits additional bits set: 0x24.



OR'ing this value in with 0x02 gives you 0x26, which you will find in the table in the article.




Reference: Comment to "Master Your Quantum" (MSDN Blogs)



The table explaining the quantum settings from the same article:



Win32PrioritySeparation Foreground Background
0x28, 0x29, 0x2A 18 18
0x18, 0x19, 0x1A 36 36
0x24 6 6
0x25, 0x14 12 6
0x26 18 6
0x15 24 6
0x16 36 6


Short Summary of OS Quantum



Based on the above information and article quotes, we know that a quantum is not a fixed size, but rather derived from an OS setting in the System Properties. A quantum varies depending on the Win32PrioritySeparation setting in the registry which normally corresponds to one of the setting in the "System Properties" (either "Background services" or "Applications").



A quantum at OS level is



  • for the "Applications" setting

    • 18 (which is 6 ticks) for foreground applications (93.75 ms)

    • 6 (which is 2 ticks) for background applications (31.25 ms)


  • for the "Background Services" setting

    • 36 (which is 18 ticks) for foreground applications (187.5 ms)

    • 36 (which is 18 ticks) for background applications (187.5 ms)


So now we know that an OS quantum on a Windows Server setup to be optimised for Background Services is ...



36 / 3 * 15.625000 ms = 187.5 ms


My Conundrum



The Server OS Quantum regulates how much time the SQL Server Service is granted to execute "tasks". The SQL Server OS Quantum is defined as 4 ms. If I divide the 187.5 ms by 4 ms then I am left with 3.5 ms.



And we haven't even started the discussion of when the Clock Interval is set to something other than the default of 15.625000 ms....



Simple Question



How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)?










share|improve this question






















  • How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)? It's not and SQL Server doesn't use preemptive scheduling. Work items are expected to hit yield points and if they don't, you get things such as NONYIELDING schedulers. There is no parity.

    – Sean Gallardy
    7 hours ago













11












11








11


1






Simple question:



How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)?




Deep Dive



In the next couple of sections I'll write up what I have found so far regarding the OS quantum and how the duration of a quantum can be calculated. The duration of an OS "quantum" is based on "ticks" and the duration of the "tick" itself is based on the "clock interval" which is normally 15.625000 ms. But let me elaborate a bit...



Tick



In the Blog article Know Thy Tick the author Jim explains the basics of clock intervals (aka "ticks") and what they are for.




When I read something like “the clock interval… for most x86 multiprocessors is about 15 milliseconds” I’m compelled to determine the value of my clock, or “tick”, interval. Fortunately, the book I read this quote in, Windows Internals Fourth Edition provides a reference for helping me with my affliction.
...
The author, Mark Russinovich, of the aforementioned book has graciously made the utility ClockRes available on his web site. Running this utility, I was able to determine that the clock interval on my x86 multiprocessor PC is 15.625000 ms. Interesting, but my curious mind wants to know more.




Quantum



The author of the article goes on to explain in his second article that...




Of course the real reason why the tick interval is important is that it affects thread scheduling. The Windows scheduler gives each thread a “quantum” of time to execute before allowing another task, at the same priority level, to run. The quantum that the scheduler assigns to a thread is a multiple of the tick interval. The specific quantum value chosen for a specific thread is bit beyond where I want to go with this article.




Ok, so I know what a quantum is, but not how long a quantum will run.




For now, let’s just examine the default quantum value for a foreground thread in XPe. In this case the Windows scheduler assigns a quantum of 18 or 6 tick intervals. (Yes, to convert quantum to tick intervals, one must divide by 3. ..., but the reason for the multiple is to allow the scheduler the ability to “charge” a thread for doing an operation which causes it to suspend.)




We now know that a clock interval (tick) should be around 15.625000 ms and on a Windows Desktop OS where the default quantum is 18 that this will result in 6 ticks or 93.750000 ms (18 / 3 * 15.625000 ms).



On a Windows Server OS the default quantum is different. The "Processor scheduling" setting is set to "Background Services"



This setting can be found via "System Settings | Advanced (tab) | Performance (section) | Settings ..." which will open "Perofrmance Options | Advanced (tab) | Processor scheduling"



The default quantum settings are then 36 (Background) to 36 (Foreground). The quantum is larger and hence longer. This is double the amount of the 93.750000 ms of the 18 (6 tick) quantum foreground setting on a Windows Desktop OS, which on a server OS set up for Background Services is around 187.500000 ms.



Observation / Explanation



When you change the setting from "Background services" to "Applicaitons" on either a server or desktop, then the HKLMSYSTEM CurrentControlSet Control PriorityControl Win32PrioritySeparation key in the registry is changed from 0x18 to 0x02. What is the default quantum value for 0x02? This can be found in a comment:




The value 0x02 implies that the "Short vs. Long" and "Variable vs. Fixed" fields are the default for the OS.



The default for these fields for XPe & XP Pro is: Short & Variable which is the same as having the following bits additional bits set: 0x24.



OR'ing this value in with 0x02 gives you 0x26, which you will find in the table in the article.




Reference: Comment to "Master Your Quantum" (MSDN Blogs)



The table explaining the quantum settings from the same article:



Win32PrioritySeparation Foreground Background
0x28, 0x29, 0x2A 18 18
0x18, 0x19, 0x1A 36 36
0x24 6 6
0x25, 0x14 12 6
0x26 18 6
0x15 24 6
0x16 36 6


Short Summary of OS Quantum



Based on the above information and article quotes, we know that a quantum is not a fixed size, but rather derived from an OS setting in the System Properties. A quantum varies depending on the Win32PrioritySeparation setting in the registry which normally corresponds to one of the setting in the "System Properties" (either "Background services" or "Applications").



A quantum at OS level is



  • for the "Applications" setting

    • 18 (which is 6 ticks) for foreground applications (93.75 ms)

    • 6 (which is 2 ticks) for background applications (31.25 ms)


  • for the "Background Services" setting

    • 36 (which is 18 ticks) for foreground applications (187.5 ms)

    • 36 (which is 18 ticks) for background applications (187.5 ms)


So now we know that an OS quantum on a Windows Server setup to be optimised for Background Services is ...



36 / 3 * 15.625000 ms = 187.5 ms


My Conundrum



The Server OS Quantum regulates how much time the SQL Server Service is granted to execute "tasks". The SQL Server OS Quantum is defined as 4 ms. If I divide the 187.5 ms by 4 ms then I am left with 3.5 ms.



And we haven't even started the discussion of when the Clock Interval is set to something other than the default of 15.625000 ms....



Simple Question



How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)?










share|improve this question














Simple question:



How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)?




Deep Dive



In the next couple of sections I'll write up what I have found so far regarding the OS quantum and how the duration of a quantum can be calculated. The duration of an OS "quantum" is based on "ticks" and the duration of the "tick" itself is based on the "clock interval" which is normally 15.625000 ms. But let me elaborate a bit...



Tick



In the Blog article Know Thy Tick the author Jim explains the basics of clock intervals (aka "ticks") and what they are for.




When I read something like “the clock interval… for most x86 multiprocessors is about 15 milliseconds” I’m compelled to determine the value of my clock, or “tick”, interval. Fortunately, the book I read this quote in, Windows Internals Fourth Edition provides a reference for helping me with my affliction.
...
The author, Mark Russinovich, of the aforementioned book has graciously made the utility ClockRes available on his web site. Running this utility, I was able to determine that the clock interval on my x86 multiprocessor PC is 15.625000 ms. Interesting, but my curious mind wants to know more.




Quantum



The author of the article goes on to explain in his second article that...




Of course the real reason why the tick interval is important is that it affects thread scheduling. The Windows scheduler gives each thread a “quantum” of time to execute before allowing another task, at the same priority level, to run. The quantum that the scheduler assigns to a thread is a multiple of the tick interval. The specific quantum value chosen for a specific thread is bit beyond where I want to go with this article.




Ok, so I know what a quantum is, but not how long a quantum will run.




For now, let’s just examine the default quantum value for a foreground thread in XPe. In this case the Windows scheduler assigns a quantum of 18 or 6 tick intervals. (Yes, to convert quantum to tick intervals, one must divide by 3. ..., but the reason for the multiple is to allow the scheduler the ability to “charge” a thread for doing an operation which causes it to suspend.)




We now know that a clock interval (tick) should be around 15.625000 ms and on a Windows Desktop OS where the default quantum is 18 that this will result in 6 ticks or 93.750000 ms (18 / 3 * 15.625000 ms).



On a Windows Server OS the default quantum is different. The "Processor scheduling" setting is set to "Background Services"



This setting can be found via "System Settings | Advanced (tab) | Performance (section) | Settings ..." which will open "Perofrmance Options | Advanced (tab) | Processor scheduling"



The default quantum settings are then 36 (Background) to 36 (Foreground). The quantum is larger and hence longer. This is double the amount of the 93.750000 ms of the 18 (6 tick) quantum foreground setting on a Windows Desktop OS, which on a server OS set up for Background Services is around 187.500000 ms.



Observation / Explanation



When you change the setting from "Background services" to "Applicaitons" on either a server or desktop, then the HKLMSYSTEM CurrentControlSet Control PriorityControl Win32PrioritySeparation key in the registry is changed from 0x18 to 0x02. What is the default quantum value for 0x02? This can be found in a comment:




The value 0x02 implies that the "Short vs. Long" and "Variable vs. Fixed" fields are the default for the OS.



The default for these fields for XPe & XP Pro is: Short & Variable which is the same as having the following bits additional bits set: 0x24.



OR'ing this value in with 0x02 gives you 0x26, which you will find in the table in the article.




Reference: Comment to "Master Your Quantum" (MSDN Blogs)



The table explaining the quantum settings from the same article:



Win32PrioritySeparation Foreground Background
0x28, 0x29, 0x2A 18 18
0x18, 0x19, 0x1A 36 36
0x24 6 6
0x25, 0x14 12 6
0x26 18 6
0x15 24 6
0x16 36 6


Short Summary of OS Quantum



Based on the above information and article quotes, we know that a quantum is not a fixed size, but rather derived from an OS setting in the System Properties. A quantum varies depending on the Win32PrioritySeparation setting in the registry which normally corresponds to one of the setting in the "System Properties" (either "Background services" or "Applications").



A quantum at OS level is



  • for the "Applications" setting

    • 18 (which is 6 ticks) for foreground applications (93.75 ms)

    • 6 (which is 2 ticks) for background applications (31.25 ms)


  • for the "Background Services" setting

    • 36 (which is 18 ticks) for foreground applications (187.5 ms)

    • 36 (which is 18 ticks) for background applications (187.5 ms)


So now we know that an OS quantum on a Windows Server setup to be optimised for Background Services is ...



36 / 3 * 15.625000 ms = 187.5 ms


My Conundrum



The Server OS Quantum regulates how much time the SQL Server Service is granted to execute "tasks". The SQL Server OS Quantum is defined as 4 ms. If I divide the 187.5 ms by 4 ms then I am left with 3.5 ms.



And we haven't even started the discussion of when the Clock Interval is set to something other than the default of 15.625000 ms....



Simple Question



How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)?







sql-server






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 9 hours ago









hot2usehot2use

8,71452459




8,71452459












  • How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)? It's not and SQL Server doesn't use preemptive scheduling. Work items are expected to hit yield points and if they don't, you get things such as NONYIELDING schedulers. There is no parity.

    – Sean Gallardy
    7 hours ago

















  • How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)? It's not and SQL Server doesn't use preemptive scheduling. Work items are expected to hit yield points and if they don't, you get things such as NONYIELDING schedulers. There is no parity.

    – Sean Gallardy
    7 hours ago
















How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)? It's not and SQL Server doesn't use preemptive scheduling. Work items are expected to hit yield points and if they don't, you get things such as NONYIELDING schedulers. There is no parity.

– Sean Gallardy
7 hours ago





How is the SQL Server Quantum (4 ms) synchronised with the Server OS Quantum (normally: 187.5 ms)? It's not and SQL Server doesn't use preemptive scheduling. Work items are expected to hit yield points and if they don't, you get things such as NONYIELDING schedulers. There is no parity.

– Sean Gallardy
7 hours ago










2 Answers
2






active

oldest

votes


















5














I'm not an expert in this, so please take my interpretation with a grain of salt.



There's an old article here that describes thread management under the SQLOS. A relevant section is copied here:




If UMS is to handle SQL Server's scheduling needs rather than allowing
Windows to do so, UMS must somehow prevent the OS from doing what it
does with every other process: schedule threads on and off the
system's processor(s) as it sees fit. How do you do that in a
preemptive OS? UMS pulls this off through some clever tricks with
Windows event objects. Each thread under UMS has an associated event
object. For purposes of scheduling, Windows ignores threads it does
not consider viable—threads that cannot run because they are in an
infinite wait state. Knowing this, UMS puts threads to sleep that it
does not want to be scheduled by having them call WaitForSingleObject
on their corresponding event object and passing INFINITE for the
timeout value. When a thread calls WaitForSingleObject to wait on an
object and passes INFINITE for the timeout value, the only way to
awaken the thread is for the object to be signaled. When UMS wants a
given thread to run, it signals the thread's corresponding event
object. This allows the thread to come out of its wait state and
permits Windows to schedule it to run on a processor.




So if I understand correctly, threads are brought out of a sleep state by the SQLOS and allowed to run until they encounter a wait or reach their 4ms quantum, after which they are put back into a sleep state. In this manner they will never reach the full Windows quantum, and there is no remainder time slice to account for.






share|improve this answer

























  • I don't think every event in SQL is governed by the SQLOS - spinlocks as an example are I believe governed by the OS scheduler.

    – George.Palacios
    6 hours ago


















5














I'm not sure what you mean by "the SQL Server Quantum (4 ms)".



The notion of a "quantum" doesn't really apply inside SQL Server. SQL Server uses a cooperative user-mode task scheduler, and tasks are expected to yield frequently, placing themselves on the runable queue of the scheduler.






share|improve this answer




















  • 3





    See this article. I've seen mention of SQL Quantums a lot over the years - not sure how true any of it is now.

    – George.Palacios
    7 hours ago







  • 3





    So there it's used to mean essentially "the time a task actually spends assigned to a worker", but that's not the same sense as a Windows quantum, which is a period of time after which the OS will remove a thread from a CPU. There's just different concepts.

    – David Browne - Microsoft
    7 hours ago











  • Yeah it seems like quite a subtle distinction but I agree. The question then becomes what happen if the OS forces a thread to end execution because the OS quantum has been reached - particularly if SQL is midway through an operation.

    – George.Palacios
    7 hours ago











  • A context switch happens SQL Server's thread is suspended, just like any other program.

    – David Browne - Microsoft
    7 hours ago











  • That, as I understand the question, is the answer in that case.

    – George.Palacios
    7 hours ago











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "182"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f237749%2fwindows-os-quantum-vs-sql-os-quantum%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














I'm not an expert in this, so please take my interpretation with a grain of salt.



There's an old article here that describes thread management under the SQLOS. A relevant section is copied here:




If UMS is to handle SQL Server's scheduling needs rather than allowing
Windows to do so, UMS must somehow prevent the OS from doing what it
does with every other process: schedule threads on and off the
system's processor(s) as it sees fit. How do you do that in a
preemptive OS? UMS pulls this off through some clever tricks with
Windows event objects. Each thread under UMS has an associated event
object. For purposes of scheduling, Windows ignores threads it does
not consider viable—threads that cannot run because they are in an
infinite wait state. Knowing this, UMS puts threads to sleep that it
does not want to be scheduled by having them call WaitForSingleObject
on their corresponding event object and passing INFINITE for the
timeout value. When a thread calls WaitForSingleObject to wait on an
object and passes INFINITE for the timeout value, the only way to
awaken the thread is for the object to be signaled. When UMS wants a
given thread to run, it signals the thread's corresponding event
object. This allows the thread to come out of its wait state and
permits Windows to schedule it to run on a processor.




So if I understand correctly, threads are brought out of a sleep state by the SQLOS and allowed to run until they encounter a wait or reach their 4ms quantum, after which they are put back into a sleep state. In this manner they will never reach the full Windows quantum, and there is no remainder time slice to account for.






share|improve this answer

























  • I don't think every event in SQL is governed by the SQLOS - spinlocks as an example are I believe governed by the OS scheduler.

    – George.Palacios
    6 hours ago















5














I'm not an expert in this, so please take my interpretation with a grain of salt.



There's an old article here that describes thread management under the SQLOS. A relevant section is copied here:




If UMS is to handle SQL Server's scheduling needs rather than allowing
Windows to do so, UMS must somehow prevent the OS from doing what it
does with every other process: schedule threads on and off the
system's processor(s) as it sees fit. How do you do that in a
preemptive OS? UMS pulls this off through some clever tricks with
Windows event objects. Each thread under UMS has an associated event
object. For purposes of scheduling, Windows ignores threads it does
not consider viable—threads that cannot run because they are in an
infinite wait state. Knowing this, UMS puts threads to sleep that it
does not want to be scheduled by having them call WaitForSingleObject
on their corresponding event object and passing INFINITE for the
timeout value. When a thread calls WaitForSingleObject to wait on an
object and passes INFINITE for the timeout value, the only way to
awaken the thread is for the object to be signaled. When UMS wants a
given thread to run, it signals the thread's corresponding event
object. This allows the thread to come out of its wait state and
permits Windows to schedule it to run on a processor.




So if I understand correctly, threads are brought out of a sleep state by the SQLOS and allowed to run until they encounter a wait or reach their 4ms quantum, after which they are put back into a sleep state. In this manner they will never reach the full Windows quantum, and there is no remainder time slice to account for.






share|improve this answer

























  • I don't think every event in SQL is governed by the SQLOS - spinlocks as an example are I believe governed by the OS scheduler.

    – George.Palacios
    6 hours ago













5












5








5







I'm not an expert in this, so please take my interpretation with a grain of salt.



There's an old article here that describes thread management under the SQLOS. A relevant section is copied here:




If UMS is to handle SQL Server's scheduling needs rather than allowing
Windows to do so, UMS must somehow prevent the OS from doing what it
does with every other process: schedule threads on and off the
system's processor(s) as it sees fit. How do you do that in a
preemptive OS? UMS pulls this off through some clever tricks with
Windows event objects. Each thread under UMS has an associated event
object. For purposes of scheduling, Windows ignores threads it does
not consider viable—threads that cannot run because they are in an
infinite wait state. Knowing this, UMS puts threads to sleep that it
does not want to be scheduled by having them call WaitForSingleObject
on their corresponding event object and passing INFINITE for the
timeout value. When a thread calls WaitForSingleObject to wait on an
object and passes INFINITE for the timeout value, the only way to
awaken the thread is for the object to be signaled. When UMS wants a
given thread to run, it signals the thread's corresponding event
object. This allows the thread to come out of its wait state and
permits Windows to schedule it to run on a processor.




So if I understand correctly, threads are brought out of a sleep state by the SQLOS and allowed to run until they encounter a wait or reach their 4ms quantum, after which they are put back into a sleep state. In this manner they will never reach the full Windows quantum, and there is no remainder time slice to account for.






share|improve this answer















I'm not an expert in this, so please take my interpretation with a grain of salt.



There's an old article here that describes thread management under the SQLOS. A relevant section is copied here:




If UMS is to handle SQL Server's scheduling needs rather than allowing
Windows to do so, UMS must somehow prevent the OS from doing what it
does with every other process: schedule threads on and off the
system's processor(s) as it sees fit. How do you do that in a
preemptive OS? UMS pulls this off through some clever tricks with
Windows event objects. Each thread under UMS has an associated event
object. For purposes of scheduling, Windows ignores threads it does
not consider viable—threads that cannot run because they are in an
infinite wait state. Knowing this, UMS puts threads to sleep that it
does not want to be scheduled by having them call WaitForSingleObject
on their corresponding event object and passing INFINITE for the
timeout value. When a thread calls WaitForSingleObject to wait on an
object and passes INFINITE for the timeout value, the only way to
awaken the thread is for the object to be signaled. When UMS wants a
given thread to run, it signals the thread's corresponding event
object. This allows the thread to come out of its wait state and
permits Windows to schedule it to run on a processor.




So if I understand correctly, threads are brought out of a sleep state by the SQLOS and allowed to run until they encounter a wait or reach their 4ms quantum, after which they are put back into a sleep state. In this manner they will never reach the full Windows quantum, and there is no remainder time slice to account for.







share|improve this answer














share|improve this answer



share|improve this answer








edited 8 hours ago

























answered 8 hours ago









ForrestForrest

2,8401822




2,8401822












  • I don't think every event in SQL is governed by the SQLOS - spinlocks as an example are I believe governed by the OS scheduler.

    – George.Palacios
    6 hours ago

















  • I don't think every event in SQL is governed by the SQLOS - spinlocks as an example are I believe governed by the OS scheduler.

    – George.Palacios
    6 hours ago
















I don't think every event in SQL is governed by the SQLOS - spinlocks as an example are I believe governed by the OS scheduler.

– George.Palacios
6 hours ago





I don't think every event in SQL is governed by the SQLOS - spinlocks as an example are I believe governed by the OS scheduler.

– George.Palacios
6 hours ago













5














I'm not sure what you mean by "the SQL Server Quantum (4 ms)".



The notion of a "quantum" doesn't really apply inside SQL Server. SQL Server uses a cooperative user-mode task scheduler, and tasks are expected to yield frequently, placing themselves on the runable queue of the scheduler.






share|improve this answer




















  • 3





    See this article. I've seen mention of SQL Quantums a lot over the years - not sure how true any of it is now.

    – George.Palacios
    7 hours ago







  • 3





    So there it's used to mean essentially "the time a task actually spends assigned to a worker", but that's not the same sense as a Windows quantum, which is a period of time after which the OS will remove a thread from a CPU. There's just different concepts.

    – David Browne - Microsoft
    7 hours ago











  • Yeah it seems like quite a subtle distinction but I agree. The question then becomes what happen if the OS forces a thread to end execution because the OS quantum has been reached - particularly if SQL is midway through an operation.

    – George.Palacios
    7 hours ago











  • A context switch happens SQL Server's thread is suspended, just like any other program.

    – David Browne - Microsoft
    7 hours ago











  • That, as I understand the question, is the answer in that case.

    – George.Palacios
    7 hours ago















5














I'm not sure what you mean by "the SQL Server Quantum (4 ms)".



The notion of a "quantum" doesn't really apply inside SQL Server. SQL Server uses a cooperative user-mode task scheduler, and tasks are expected to yield frequently, placing themselves on the runable queue of the scheduler.






share|improve this answer




















  • 3





    See this article. I've seen mention of SQL Quantums a lot over the years - not sure how true any of it is now.

    – George.Palacios
    7 hours ago







  • 3





    So there it's used to mean essentially "the time a task actually spends assigned to a worker", but that's not the same sense as a Windows quantum, which is a period of time after which the OS will remove a thread from a CPU. There's just different concepts.

    – David Browne - Microsoft
    7 hours ago











  • Yeah it seems like quite a subtle distinction but I agree. The question then becomes what happen if the OS forces a thread to end execution because the OS quantum has been reached - particularly if SQL is midway through an operation.

    – George.Palacios
    7 hours ago











  • A context switch happens SQL Server's thread is suspended, just like any other program.

    – David Browne - Microsoft
    7 hours ago











  • That, as I understand the question, is the answer in that case.

    – George.Palacios
    7 hours ago













5












5








5







I'm not sure what you mean by "the SQL Server Quantum (4 ms)".



The notion of a "quantum" doesn't really apply inside SQL Server. SQL Server uses a cooperative user-mode task scheduler, and tasks are expected to yield frequently, placing themselves on the runable queue of the scheduler.






share|improve this answer















I'm not sure what you mean by "the SQL Server Quantum (4 ms)".



The notion of a "quantum" doesn't really apply inside SQL Server. SQL Server uses a cooperative user-mode task scheduler, and tasks are expected to yield frequently, placing themselves on the runable queue of the scheduler.







share|improve this answer














share|improve this answer



share|improve this answer








edited 5 hours ago

























answered 8 hours ago









David Browne - MicrosoftDavid Browne - Microsoft

13.2k936




13.2k936







  • 3





    See this article. I've seen mention of SQL Quantums a lot over the years - not sure how true any of it is now.

    – George.Palacios
    7 hours ago







  • 3





    So there it's used to mean essentially "the time a task actually spends assigned to a worker", but that's not the same sense as a Windows quantum, which is a period of time after which the OS will remove a thread from a CPU. There's just different concepts.

    – David Browne - Microsoft
    7 hours ago











  • Yeah it seems like quite a subtle distinction but I agree. The question then becomes what happen if the OS forces a thread to end execution because the OS quantum has been reached - particularly if SQL is midway through an operation.

    – George.Palacios
    7 hours ago











  • A context switch happens SQL Server's thread is suspended, just like any other program.

    – David Browne - Microsoft
    7 hours ago











  • That, as I understand the question, is the answer in that case.

    – George.Palacios
    7 hours ago












  • 3





    See this article. I've seen mention of SQL Quantums a lot over the years - not sure how true any of it is now.

    – George.Palacios
    7 hours ago







  • 3





    So there it's used to mean essentially "the time a task actually spends assigned to a worker", but that's not the same sense as a Windows quantum, which is a period of time after which the OS will remove a thread from a CPU. There's just different concepts.

    – David Browne - Microsoft
    7 hours ago











  • Yeah it seems like quite a subtle distinction but I agree. The question then becomes what happen if the OS forces a thread to end execution because the OS quantum has been reached - particularly if SQL is midway through an operation.

    – George.Palacios
    7 hours ago











  • A context switch happens SQL Server's thread is suspended, just like any other program.

    – David Browne - Microsoft
    7 hours ago











  • That, as I understand the question, is the answer in that case.

    – George.Palacios
    7 hours ago







3




3





See this article. I've seen mention of SQL Quantums a lot over the years - not sure how true any of it is now.

– George.Palacios
7 hours ago






See this article. I've seen mention of SQL Quantums a lot over the years - not sure how true any of it is now.

– George.Palacios
7 hours ago





3




3





So there it's used to mean essentially "the time a task actually spends assigned to a worker", but that's not the same sense as a Windows quantum, which is a period of time after which the OS will remove a thread from a CPU. There's just different concepts.

– David Browne - Microsoft
7 hours ago





So there it's used to mean essentially "the time a task actually spends assigned to a worker", but that's not the same sense as a Windows quantum, which is a period of time after which the OS will remove a thread from a CPU. There's just different concepts.

– David Browne - Microsoft
7 hours ago













Yeah it seems like quite a subtle distinction but I agree. The question then becomes what happen if the OS forces a thread to end execution because the OS quantum has been reached - particularly if SQL is midway through an operation.

– George.Palacios
7 hours ago





Yeah it seems like quite a subtle distinction but I agree. The question then becomes what happen if the OS forces a thread to end execution because the OS quantum has been reached - particularly if SQL is midway through an operation.

– George.Palacios
7 hours ago













A context switch happens SQL Server's thread is suspended, just like any other program.

– David Browne - Microsoft
7 hours ago





A context switch happens SQL Server's thread is suspended, just like any other program.

– David Browne - Microsoft
7 hours ago













That, as I understand the question, is the answer in that case.

– George.Palacios
7 hours ago





That, as I understand the question, is the answer in that case.

– George.Palacios
7 hours ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Database Administrators Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f237749%2fwindows-os-quantum-vs-sql-os-quantum%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Log på Navigationsmenu

Wonderful Copenhagen (sang) Eksterne henvisninger | NavigationsmenurSide på frankloesser.comWonderful Copenhagen

Detroit Tigers Spis treści Historia | Skład zespołu | Sukcesy | Członkowie Baseball Hall of Fame | Zastrzeżone numery | Przypisy | Menu nawigacyjneEncyclopedia of Detroit - Detroit TigersTigers Stadium, Detroit, MITigers Timeline 1900sDetroit Tigers Team History & EncyclopediaTigers Timeline 1910s1935 World Series1945 World Series1945 World Series1984 World SeriesComerica Park, Detroit, MI2006 World Series2012 World SeriesDetroit Tigers 40-Man RosterDetroit Tigers Coaching StaffTigers Hall of FamersTigers Retired Numberse