Changeset 39510 in vbox for trunk/src/VBox/Runtime/common/misc/reqpool.cpp
- Timestamp:
- Dec 2, 2011 10:58:29 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/reqpool.cpp
r39500 r39510 34 34 #include <iprt/assert.h> 35 35 #include <iprt/asm.h> 36 #include <iprt/critsect.h> 37 #include <iprt/list.h> 38 #include <iprt/log.h> 39 #include <iprt/mem.h> 36 40 #include <iprt/string.h> 37 41 #include <iprt/time.h> 38 42 #include <iprt/semaphore.h> 39 43 #include <iprt/thread.h> 40 #include <iprt/log.h>41 #include <iprt/mem.h>42 44 43 45 #include "internal/req.h" … … 45 47 46 48 49 /******************************************************************************* 50 * Structures and Typedefs * 51 *******************************************************************************/ 52 typedef struct RTREQPOOLTHREAD 53 { 54 /** Node in the RTREQPOOLINT::IdleThreads list. */ 55 RTLISTNODE IdleNode; 56 /** Node in the RTREQPOOLINT::WorkerThreads list. */ 57 RTLISTNODE ListNode; 58 59 /** The submit timestamp of the pending request. */ 60 uint64_t uPendingNanoTs; 61 /** When this CPU went idle the last time. */ 62 uint64_t uIdleNanoTs; 63 /** The number of requests processed by this thread. */ 64 uint64_t cReqProcessed; 65 /** Total time the requests processed by this thread took to process. */ 66 uint64_t cNsTotalReqProcessing; 67 /** Total time the requests processed by this thread had to wait in 68 * the queue before being scheduled. */ 69 uint64_t cNsTotalReqQueued; 70 /** The CPU this was scheduled last time we checked. */ 71 RTCPUID idLastCpu; 72 73 /** The thread handle. */ 74 RTTHREAD hThread; 75 76 /** The submitter will put an incoming request here when scheduling an idle 77 * thread. */ 78 PRTREQINT volatile pTodoReq; 79 /** The request the thread is currently processing. */ 80 PRTREQINT volatile pPendingReq; 81 82 } RTREQPOOLTHREAD; 83 84 typedef struct RTREQPOOLINT 85 { 86 /** Magic value (RTREQPOOL_MAGIC). */ 87 uint32_t u32Magic; 88 89 /** The current number of worker threads. */ 90 uint32_t cCurThreads; 91 /** The maximum number of worker threads. */ 92 uint32_t cMaxThreads; 93 /** The number of threads which should be spawned before throttling kicks 94 * in. */ 95 uint32_t cThreadsThreshold; 96 /** The minimum number of worker threads. */ 97 uint32_t cMinThreads; 98 /** The number of milliseconds a thread needs to be idle before it is 99 * considered for retirement. */ 100 uint32_t cMsMinIdle; 101 102 /** Statistics: The total number of threads created. */ 103 uint32_t cThreadsCreated; 104 /** Statistics: The timestamp when the last thread was created. */ 105 uint64_t uLastThreadCreateNanoTs; 106 /** Linked list of worker threads. */ 107 RTLISTANCHOR WorkerThreads; 108 109 /** Critical section serializing access to members of this structure. */ 110 RTCRITSECT CritSect; 111 112 /** Reference counter. */ 113 uint32_t volatile cRefs; 114 /** Linked list of idle threads. */ 115 RTLISTANCHOR IdleThreads; 116 117 118 } RTREQPOOLINT; 119 /** Pointer to a request thread pool instance. */ 120 typedef RTREQPOOLINT *PRTREQPOOLINT; 121
Note:
See TracChangeset
for help on using the changeset viewer.