/* * Initializes a pipe */ void PipeInit( char * buff, COUNT size, struct PIPE * pipe ) { SemaphoreInit( & pipe->Mutex, 1 ); SemaphoreInit( & pipe->ReaderLock, 0 ); //Buffer starts empty, to it is not readable. Semaphore starts locked SemaphoreInit( & pipe->WriterLock, 1 );//Buffer starts empty, so it is writable. Semaphore started unlocked. RingBufferInit( buff, size, & pipe->Ring ); }
/* * Initializes a pipe */ void PipeInit( char * buff, COUNT size, struct PIPE * pipe, PIPE_READ * pr, PIPE_WRITE * pw ) { SemaphoreInit( & pipe->Mutex, 1 ); SemaphoreInit( & pipe->EmptyLock, 0 ); //Buffer starts empty, block reads. SemaphoreInit( & pipe->FullLock, 1 );//Buffer starts empty, allow writes. SemaphoreInit( & pipe->ReadLock, 1 ); SemaphoreInit( & pipe->WriteLock, 1 ); RingBufferInit( buff, size, & pipe->Ring ); * pr = pipe; * pw = pipe; }
ConsoleDrv() : m_conX(0), m_conY(0) { m_stat.structSize = sizeof(m_stat); m_stat.flags = StrmDev_Writable; m_stat.size = 0; // don't care m_fbInfo.structSize = sizeof(m_fbInfo); SemaphoreInit(&conMutex, 1); }
int THQCreate(THQueue *pQueue_Arg) #ifdef BODYDEF { assert(pQueue_Arg); /* Allocate the buffer */ pQueue_Arg->ppBuf = malloc(sizeof(char *)*THQUEUE_SIZE); assert(pQueue_Arg->ppBuf); MutexInit(&pQueue_Arg->Lock); SemaphoreInit(&pQueue_Arg->Empty, THQUEUE_SIZE); SemaphoreInit(&pQueue_Arg->Full, 0); pQueue_Arg->Size = THQUEUE_SIZE; pQueue_Arg->Head = 0; pQueue_Arg->Tail = 0; return 0; }
void WorkerCreateWorker( struct WORKER_QUEUE * queue, char * stack, unsigned int stackSize) { LinkedListInit( &queue->List ); SemaphoreInit( &queue->Lock, 0 ); SchedulerCreateThread( &queue->Thread, 10, stack, stackSize, WorkerThreadMain, queue, TRUE); }