#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <tchar.h>
#include <windows.h>
Go to the source code of this file.
◆ FIBERTEST_COUNT
◆ InitializeListHead
#define InitializeListHead |
( |
|
PLH__ | ) |
((PLH__)->Flink = (PLH__)->Blink = (PLH__)) |
◆ InsertTailList
#define InsertTailList |
( |
|
PLH__, |
|
|
|
PLE__ |
|
) |
| |
Value:{ \
\
(PLE__)->Flink = pleListHead__; \
(PLE__)->Blink = pleBlink__; \
pleBlink__->
Flink = (PLE__); \
pleListHead__->
Blink = (PLE__); \
}
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
struct _LIST_ENTRY * PLIST_ENTRY
Definition at line 33 of file fiber.c.
◆ IsListEmpty
#define IsListEmpty |
( |
|
PLH__ | ) |
((PLH__)->Flink == (PVOID)(PLH__)) |
◆ RemoveEntryList
#define RemoveEntryList |
( |
|
PLE__ | ) |
|
Value:{ \
\
pleBack__->
Flink = pleForward__; \
pleForward__->
Blink = pleBack__; \
}
Definition at line 20 of file fiber.c.
◆ RemoveHeadList
#define RemoveHeadList |
( |
|
PLH__ | ) |
|
Value:
Definition at line 48 of file fiber.c.
◆ _tmain()
Definition at line 420 of file fiber.c.
421{
423 unsigned nFibers;
424
427 else
429
430 for(
i = 0;
i < 32; ++
i)
431 {
433 }
434
435 for(
i = 0;
i < nFibers; ++
i)
437
439
440 return 0;
441}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define InitializeListHead(PLH__)
VOID CALLBACK Fbt_Startup(PVOID)
static LIST_ENTRY a_leQueues[32]
void Fbt_CreateFiber(int bInitial)
FORCEINLINE PVOID GetFiberData(VOID)
◆ DoStuff()
Definition at line 391 of file fiber.c.
392{
395 unsigned nId;
396
399
401
402 for(
i = 0;
i <
n; ++
i)
403 {
406
408
410
411 for(
j = 0;
j <
m; ++
j)
413
415 }
416
418}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_Check_return_ int __cdecl rand(void)
unsigned Fbt_GetCurrentId(void)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Referenced by Fbt_Startup().
◆ Fbt_AfterSwitch()
Definition at line 113 of file fiber.c.
114{
116
118
119
121 {
122
124 {
127
130 }
131
132 else
133 {
134
136
137
139 {
142 }
143
144
146 (
149 );
150 }
151 }
152}
VOID WINAPI DeleteFiber(_In_ LPVOID lpFiber)
#define InsertTailList(ListHead, Entry)
static struct FiberData * pfdLastStarveScan
struct FiberData * pfdPrev
Referenced by Fbt_Dispatch(), and Fbt_Startup().
◆ Fbt_Create()
◆ Fbt_CreateFiber()
void Fbt_CreateFiber |
( |
int |
bInitial | ) |
|
Definition at line 338 of file fiber.c.
339{
342 static int s_bFiberPrioSeeded = 0;
343 static LONG s_nFiberIdSeed = 0;
344
346
348
349 if(bInitial)
351 else
353
354 if(!s_bFiberPrioSeeded)
355 {
356 unsigned nFiberPrioSeed;
358
360 memcpy(&nFiberPrioSeed, &tCurTime,
sizeof(nFiberPrioSeed));
361 srand(nFiberPrioSeed);
362 s_bFiberPrioSeeded = 1;
363 }
364
366
367 pData->nMagic = 0x12345678;
371 pData->nQuantumQueued = 0;
375 pData->bExitPrev = 0;
376
377 if(bInitial)
378 {
380 }
381 else
382 {
384 (
387 );
388 }
389}
#define InterlockedIncrement
LPVOID WINAPI ConvertThreadToFiber(_In_opt_ LPVOID lpParameter)
LPVOID WINAPI CreateFiber(_In_ SIZE_T dwStackSize, _In_ LPFIBER_START_ROUTINE lpStartAddress, _In_opt_ LPVOID lpParameter)
void __cdecl srand(_In_ unsigned int _Seed)
#define memcpy(s1, s2, n)
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Referenced by _tmain().
◆ Fbt_Dispatch()
Definition at line 162 of file fiber.c.
163{
167
169
171
172
173
175 {
179 int bResume;
181
182 bResume = 0;
184
185
187 {
189
191
192
194
196
198
200
201 else
202 {
205 bResume = 1;
206 }
207
208
210 {
211 if(bResume)
212 bResume = 0;
213
215 }
216 }
217
218
219
220
221
222 for(
j = 0,
k = 0,
b = 0;
j < 16 &&
k < 15 &&
b < 10; ++
j)
223 {
224 unsigned nDiff;
225
226
227 if(!bResume)
228 {
229 int nQueue;
230
231
232 nQueue = (
k +
i) % 15;
233
235 {
237 continue;
238 }
239
241 }
242 else
243 bResume = 0;
244
245
249
250
253 else
255
256
257 if(nDiff > 30)
258 {
259
261
262
266
267
270 }
271 }
272 }
273
275
276
279
280
281
282
283 else
285
286
287 for(
i = 32;
i >=
n; --
i)
288 {
290
291
293 continue;
294
295
301 break;
302 }
303
304
305 if(pfdNext)
306 {
307
310
311
313
314
316 }
317
319 {
321
322
325
326 pCurFiber = pfdCur->
pFiber;
329 }
330
331}
#define RemoveEntryList(Entry)
GLboolean GLboolean GLboolean b
#define RemoveHeadList(PLH__)
#define IsListEmpty(PLH__)
void Fbt_AfterSwitch(struct FiberData *)
#define CONTAINING_RECORD(address, type, field)
void WINAPI SwitchToFiber(_In_ PVOID)
Referenced by Fbt_Exit(), and Fbt_Yield().
◆ Fbt_Exit()
Definition at line 333 of file fiber.c.
334{
336}
void Fbt_Dispatch(struct FiberData *, int)
Referenced by Fbt_Startup().
◆ Fbt_GetCurrent()
◆ Fbt_GetCurrentId()
Definition at line 91 of file fiber.c.
92{
94}
struct FiberData * Fbt_GetCurrent(void)
Referenced by DoStuff().
◆ Fbt_Startup()
◆ Fbt_Yield()
Definition at line 96 of file fiber.c.
97{
99
101
103 {
105
108 }
109 else if((
rand() % 100) > 50 - (45 * pfdCur->
nPrio) / 32)
111}
Referenced by DoStuff().
◆ a_leQueues
◆ nQuantum
◆ pfdLastStarveScan