SDL
2.0
|
Go to the source code of this file.
Data Structures | |
struct | SDL_EventQueueEntry |
struct | SDL_EventQueue |
struct | WriterData |
struct | ReaderData |
Macros | |
#define | NThreads 2 |
#define | CountInc 100 |
#define | VALBITS (sizeof(atomicValue)*8) |
#define | atomicValue int |
#define | CountTo ((atomicValue)((unsigned int)(1<<(VALBITS-1))-1)) |
#define | NInter (CountTo/CountInc/NThreads) |
#define | Expect (CountTo-NInter*CountInc*NThreads) |
#define | TEST_SPINLOCK_FIFO |
#define | NUM_READERS 4 |
#define | NUM_WRITERS 4 |
#define | EVENTS_PER_WRITER 1000000 |
#define | MAX_ENTRIES 256 |
#define | WRAP_MASK (MAX_ENTRIES-1) |
Enumerations | |
enum | |
Functions | |
static char * | tf (SDL_bool tf) |
static void | RunBasicTest () |
SDL_COMPILE_TIME_ASSERT (size, CountTo_GreaterThanZero) | |
static int | adder (void *junk) |
static void | runAdder (void) |
static void | RunEpicTest () |
static void | InitEventQueue (SDL_EventQueue *queue) |
static SDL_bool | EnqueueEvent_LockFree (SDL_EventQueue *queue, const SDL_Event *event) |
static SDL_bool | DequeueEvent_LockFree (SDL_EventQueue *queue, SDL_Event *event) |
static SDL_bool | EnqueueEvent_Mutex (SDL_EventQueue *queue, const SDL_Event *event) |
static SDL_bool | DequeueEvent_Mutex (SDL_EventQueue *queue, SDL_Event *event) |
static int | FIFO_Writer (void *_data) |
static int | FIFO_Reader (void *_data) |
static int | FIFO_Watcher (void *_data) |
static void | RunFIFOTest (SDL_bool lock_free) |
int | main (int argc, char *argv[]) |
Variables | |
static SDL_atomic_t | good = { 42 } |
static atomicValue | bad = 42 |
static SDL_atomic_t | threadsRunning |
static SDL_sem * | threadDone |
static SDL_sem * | writersDone |
static SDL_sem * | readersDone |
static SDL_atomic_t | writersRunning |
static SDL_atomic_t | readersRunning |
#define atomicValue int |
Definition at line 101 of file testatomic.c.
Referenced by RunEpicTest().
#define CountInc 100 |
Definition at line 98 of file testatomic.c.
Referenced by adder().
#define CountTo ((atomicValue)((unsigned int)(1<<(VALBITS-1))-1)) |
Definition at line 102 of file testatomic.c.
Referenced by RunEpicTest().
#define EVENTS_PER_WRITER 1000000 |
Definition at line 256 of file testatomic.c.
Referenced by FIFO_Writer(), and RunFIFOTest().
Definition at line 104 of file testatomic.c.
Referenced by RunEpicTest().
#define MAX_ENTRIES 256 |
Definition at line 259 of file testatomic.c.
Referenced by DequeueEvent_LockFree(), DequeueEvent_Mutex(), and InitEventQueue().
Definition at line 103 of file testatomic.c.
Referenced by adder().
#define NThreads 2 |
Definition at line 97 of file testatomic.c.
Referenced by runAdder().
#define NUM_READERS 4 |
Definition at line 254 of file testatomic.c.
Referenced by RunFIFOTest().
#define NUM_WRITERS 4 |
Definition at line 255 of file testatomic.c.
Referenced by RunFIFOTest().
#define TEST_SPINLOCK_FIFO |
Definition at line 252 of file testatomic.c.
#define VALBITS (sizeof(atomicValue)*8) |
Definition at line 99 of file testatomic.c.
#define WRAP_MASK (MAX_ENTRIES-1) |
Definition at line 260 of file testatomic.c.
Referenced by DequeueEvent_LockFree(), DequeueEvent_Mutex(), EnqueueEvent_LockFree(), and EnqueueEvent_Mutex().
anonymous enum |
Definition at line 106 of file testatomic.c.
|
static |
Definition at line 120 of file testatomic.c.
References bad, CountInc, NInter, SDL_AtomicAdd, SDL_Log, SDL_SemPost, and threadDone.
Referenced by runAdder().
|
static |
Definition at line 361 of file testatomic.c.
References SDL_EventQueue::dequeue_pos, SDL_EventQueue::entries, SDL_EventQueueEntry::event, SDL_EventQueue::lock, MAX_ENTRIES, SDL_EventQueue::rwcount, SDL_assert, SDL_AtomicCAS, SDL_AtomicDecRef, SDL_AtomicGet, SDL_AtomicIncRef, SDL_AtomicLock, SDL_AtomicSet, SDL_AtomicUnlock, SDL_FALSE, SDL_TRUE, SDL_EventQueueEntry::sequence, SDL_EventQueue::watcher, and WRAP_MASK.
Referenced by FIFO_Reader().
|
static |
Definition at line 441 of file testatomic.c.
References SDL_EventQueue::dequeue_pos, SDL_EventQueue::entries, SDL_EventQueueEntry::event, MAX_ENTRIES, SDL_EventQueue::mutex, SDL_FALSE, SDL_LockMutex, SDL_Log, SDL_TRUE, SDL_UnlockMutex, SDL_EventQueueEntry::sequence, SDL_atomic_t::value, and WRAP_MASK.
Referenced by FIFO_Reader().
|
static |
Definition at line 314 of file testatomic.c.
References SDL_EventQueue::enqueue_pos, SDL_EventQueue::entries, SDL_EventQueueEntry::event, SDL_EventQueue::lock, SDL_EventQueue::rwcount, SDL_assert, SDL_AtomicCAS, SDL_AtomicDecRef, SDL_AtomicGet, SDL_AtomicIncRef, SDL_AtomicLock, SDL_AtomicSet, SDL_AtomicUnlock, SDL_FALSE, SDL_TRUE, SDL_EventQueueEntry::sequence, SDL_EventQueue::watcher, and WRAP_MASK.
Referenced by FIFO_Writer().
|
static |
Definition at line 408 of file testatomic.c.
References SDL_EventQueue::enqueue_pos, SDL_EventQueue::entries, SDL_EventQueueEntry::event, SDL_EventQueue::mutex, SDL_FALSE, SDL_LockMutex, SDL_Log, SDL_TRUE, SDL_UnlockMutex, SDL_EventQueueEntry::sequence, SDL_atomic_t::value, and WRAP_MASK.
Referenced by FIFO_Writer().
|
static |
Definition at line 533 of file testatomic.c.
References SDL_EventQueue::active, ReaderData::counters, SDL_UserEvent::data1, DequeueEvent_LockFree(), DequeueEvent_Mutex(), WriterData::index, ReaderData::lock_free, ReaderData::queue, readersDone, SDL_AtomicAdd, SDL_AtomicGet, SDL_Delay, SDL_SemPost, SDL_Event::user, and ReaderData::waits.
Referenced by RunFIFOTest().
|
static |
Definition at line 573 of file testatomic.c.
References SDL_EventQueue::active, SDL_EventQueue::lock, SDL_EventQueue::rwcount, SDL_AtomicDecRef, SDL_AtomicGet, SDL_AtomicIncRef, SDL_AtomicLock, SDL_AtomicUnlock, SDL_Delay, and SDL_EventQueue::watcher.
Referenced by RunFIFOTest().
|
static |
Definition at line 498 of file testatomic.c.
References EnqueueEvent_LockFree(), EnqueueEvent_Mutex(), EVENTS_PER_WRITER, i, WriterData::lock_free, NULL, WriterData::queue, SDL_AtomicAdd, SDL_Delay, SDL_SemPost, SDL_USEREVENT, WriterData::waits, and writersDone.
Referenced by RunFIFOTest().
|
static |
Definition at line 297 of file testatomic.c.
References SDL_EventQueue::active, SDL_EventQueue::dequeue_pos, SDL_EventQueue::enqueue_pos, SDL_EventQueue::entries, i, SDL_EventQueue::lock, MAX_ENTRIES, SDL_EventQueue::rwcount, SDL_AtomicSet, SDL_EventQueueEntry::sequence, and SDL_EventQueue::watcher.
Referenced by RunFIFOTest().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 712 of file testatomic.c.
References RunBasicTest(), RunEpicTest(), RunFIFOTest(), SDL_FALSE, SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, SDL_LogSetPriority, and SDL_TRUE.
Definition at line 134 of file testatomic.c.
References adder(), NThreads, NULL, SDL_AtomicGet, SDL_AtomicSet, SDL_CreateSemaphore, SDL_CreateThread, SDL_DestroySemaphore, SDL_GetTicks(), SDL_Log, SDL_SemWait, T, and threadDone.
Referenced by RunEpicTest().
|
static |
Definition at line 37 of file testatomic.c.
References lock, SDL_AtomicAdd, SDL_AtomicCAS, SDL_AtomicDecRef, SDL_AtomicGet, SDL_AtomicIncRef, SDL_AtomicLock, SDL_AtomicSet, SDL_AtomicUnlock, SDL_FALSE, SDL_Log, SDL_TRUE, and tf().
Referenced by main().
|
static |
Definition at line 159 of file testatomic.c.
References atomicValue, bad, CountTo, Expect, runAdder(), SDL_assert, SDL_AtomicAdd, SDL_AtomicCAS, SDL_AtomicGet, SDL_AtomicSet, and SDL_Log.
Referenced by main().
Definition at line 594 of file testatomic.c.
References SDL_EventQueue::active, ReaderData::counters, EVENTS_PER_WRITER, FIFO_Reader(), FIFO_Watcher(), FIFO_Writer(), i, WriterData::index, InitEventQueue(), j, WriterData::lock_free, ReaderData::lock_free, SDL_EventQueue::mutex, NUM_READERS, NUM_WRITERS, WriterData::queue, ReaderData::queue, readersDone, SDL_AtomicGet, SDL_AtomicSet, SDL_CreateMutex, SDL_CreateSemaphore, SDL_CreateThread, SDL_DestroyMutex, SDL_DestroySemaphore, SDL_GetTicks(), SDL_Log, SDL_memset, SDL_SemWait, SDL_snprintf, SDL_strlen, SDL_zero, and writersDone.
Referenced by main().
SDL_COMPILE_TIME_ASSERT | ( | size | , |
CountTo_GreaterThanZero | |||
) |
|
static |
|
static |
Definition at line 113 of file testatomic.c.
Referenced by adder(), and RunEpicTest().
|
static |
Definition at line 111 of file testatomic.c.
|
static |
Definition at line 475 of file testatomic.c.
Referenced by FIFO_Reader(), and RunFIFOTest().
|
static |
Definition at line 477 of file testatomic.c.
|
static |
Definition at line 117 of file testatomic.c.
Referenced by adder(), and runAdder().
|
static |
Definition at line 115 of file testatomic.c.
|
static |
Definition at line 474 of file testatomic.c.
Referenced by FIFO_Writer(), and RunFIFOTest().
|
static |
Definition at line 476 of file testatomic.c.