SPID Execution Model

Figure 1: Execution Model – Running, runnableand suspended status, Runnable Queue and Wait List

 

Figure 2 shows how SQL Serversessions rotate between the following statuses: Running (only one session can be running or executing, perscheduler), Runnable (sessionswaiting for CPU), or Suspended.  SPIDs with suspended statuses are placedin Waiter List until the requested resources are available. If a running sessionneeds a data page that is not in cache, or needs a page that is blocked byanother user’s lock, the session is moved to the wait list. The next SPID or session_idin the runnable queue is scheduled to start running. 

Figure 2: Execution Model – How status changesaffect SPIDs

 

The status change sequence of events is as follows:

  1. SPID60 needs a page not in cache.  Thus its status changes from Running to Suspended with wait type IO_Completion
  2. SPID60 moved to Waiter List
  3. SPID51 moves from Runnable queue with a runnable status to Running status, SPID64 then moves to the top of the Runnable queue
  4. SPID56 is waiting for a parallel process to complete.  When the parallel process is completed, the status for SPID56 changes from Suspended with wait type CXPACKET to Runnable
  5. SPID56 moved to the bottom of the Runnable queue

 

Figure 3 depictsexecution “after” session_ids (or SPIDs) have rotated clockwise due to statuschanges. 

 

Figure 3: Execution Model – After statuschange

The wait list means a thread has to wait for aresource. Example of resource waits includes IOs to complete, a lock to bereleased, a memory grant, and so on. When the session is moved to the waitlist, a wait type is assigned and time is accumulated. When the resourcebecomes available, the thread is moved to the runnable queue and it executes assoon as the CPU is available.  Theclockwise rotation between running, runnable and suspended states continuesuntil the user request is completed.


A session status of ‘Sleeping’ indicates SQL Server is waiting for thenext SQL Server command.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值