本文整理汇总了C++中semaphore_signal函数的典型用法代码示例。如果您正苦于以下问题:C++ semaphore_signal函数的具体用法?C++ semaphore_signal怎么用?C++ semaphore_signal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了semaphore_signal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: monitor_leave
/**
* Placed at the end of all monitor functions, this leaves a monitor.
*/
void monitor_leave(monitor_t *monitor) {
if (monitor->next_count > 0) {
semaphore_signal(monitor->sem_id, NEXT_SEM);
} else {
semaphore_signal(monitor->sem_id, MUTEX_SEM);
}
}
开发者ID:gundermanc,项目名称:eeccs398-os-and-concurrency,代码行数:10,代码来源:monitor.c
示例2: vsync_isr
static int vsync_isr(void *data)
{
stm_display_output_handle_interrupts(pOutput);
topfields++;
if((topfields % framerate) == 0)
{
semaphore_signal(framerate_sem);
}
semaphore_signal(frameupdate_sem);
if(pHDMI)
{
stm_display_status_t oldDisplayStatus = currentDisplayStatus;
stm_display_output_get_status(pHDMI, ¤tDisplayStatus);
if(hotplug_poll_pio)
{
unsigned char hotplugstate = *hotplug_poll_pio & hotplug_pio_pin;
if(currentDisplayStatus == STM_DISPLAY_DISCONNECTED)
{
/*
* If the device has just been plugged in, flag that we now need to
* start the output.
*/
if(hotplugstate != 0)
{
currentDisplayStatus = STM_DISPLAY_NEEDS_RESTART;
stm_display_output_set_status(pHDMI, currentDisplayStatus);
}
}
else
{
/*
* We may either be waiting for the output to be started, or already
* started, so only change the state if the device has now been
* disconnected.
*/
if(hotplugstate == 0)
{
currentDisplayStatus = STM_DISPLAY_DISCONNECTED;
stm_display_output_set_status(pHDMI, currentDisplayStatus);
}
}
}
if(oldDisplayStatus != currentDisplayStatus)
{
semaphore_signal(hotplug_sem);
}
}
return OS21_SUCCESS;
}
开发者ID:Audioniek,项目名称:Fortis-4G,代码行数:58,代码来源:progressive_display.cpp
示例3: queue_push
void queue_push(Queue *queue, int item) {
semaphore_wait(queue->spaces);
semaphore_wait(queue->mutex);
queue->array[queue->next_in] = item;
queue->next_in = queue_incr(queue, queue->next_in);
semaphore_signal(queue->mutex);
semaphore_signal(queue->items);
}
开发者ID:AllenDowney,项目名称:ThinkOS,代码行数:10,代码来源:queue_mysem_soln.c
示例4: start_routine
void *
start_routine(void *id)
{
semaphore_signal(g_sem[1]);
fprintf(stderr, "thread: %lx about to decrement semaphore count\n", id);
semaphore_wait(g_sem[0]);
fprintf(stderr, "thread: %lx succeeded in decrementing semaphore count\n", id);
semaphore_signal(g_sem[1]);
return NULL;
}
开发者ID:010001111,项目名称:darling,代码行数:10,代码来源:mach_semaphore.c
示例5: monitor_cond_wait
/**
* Waits on the specified condition variable in the monitor.
* cond is the zero based index of the condition variable which
* must be less than the number of condition variables the monitor
* was created with.
*/
void monitor_cond_wait(monitor_t *monitor, int cond) {
monitor->x_count[cond]++;
if (monitor->next_count > 0) {
semaphore_signal(monitor->sem_id, NEXT_SEM);
} else {
semaphore_signal(monitor->sem_id, MUTEX_SEM);
}
semaphore_wait(monitor->sem_id, MONITOR_SEM_COUNT + cond);
monitor->x_count[cond]--;
}
开发者ID:gundermanc,项目名称:eeccs398-os-and-concurrency,代码行数:18,代码来源:monitor.c
示例6: queue_pop
int queue_pop(Queue *queue) {
semaphore_wait(queue->items);
semaphore_wait(queue->mutex);
int item = queue->array[queue->next_out];
queue->next_out = queue_incr(queue, queue->next_out);
semaphore_signal(queue->mutex);
semaphore_signal(queue->spaces);
return item;
}
开发者ID:AllenDowney,项目名称:ThinkOS,代码行数:12,代码来源:queue_mysem_soln.c
示例7: bounded_buffer_add
/*
* Add an integer to the buffer. Yield control to another
* thread if the buffer is full.
*/
void bounded_buffer_add(BoundedBuffer *bufp, const BufferElem *elem) {
/* Not adding until the queue is known to not be full */
semaphore_wait(bufp->full_sema);
/* Accessing the mutex semaphore, to ensure only one thread is running */
semaphore_wait(bufp->single_sema);
/* Now the buffer has space */
bufp->buffer[(bufp->first + bufp->count) % bufp->length] = *elem;
bufp->count++;
/* Signaling that this thread is done with the buffer */
semaphore_signal(bufp->single_sema);
/* Incrementing the empty sema */
semaphore_signal(bufp->empty_sema);
}
开发者ID:averymarshall,项目名称:projects,代码行数:17,代码来源:bounded_buffer.c
示例8: DbgIOLog
IOReturn com_ximeta_driver_NDASDiskArrayController::receiveMsg ( void * newRequest, void *command, void *, void * )
{
DbgIOLog(DEBUG_MASK_NDAS_TRACE, ("receiveMsg: Entered\n"));
switch((int)newRequest) {
case kNDASCommandQueueAppend:
{
DbgIOLog(DEBUG_MASK_NDAS_INFO, ("Append Command!!!\n"));
if(!command) {
DbgIOLog(DEBUG_MASK_NDAS_INFO, ("No Command!!!\n"));
return kIOReturnBadArgument;
}
com_ximeta_driver_NDASCommand *tempCommand = (com_ximeta_driver_NDASCommand *)command;
fCommandArray->setObject(tempCommand);
if( 1 == fCommandArray->getCount() ) {
// Notify to the worker thread.
semaphore_signal(fCommandSema);
}
}
break;
case kNDASCommandQueueCompleteCommand:
{
DbgIOLog(DEBUG_MASK_NDAS_INFO, ("Complete Command!!!\n"));
// com_ximeta_driver_NDASCommand *tempCommand = (com_ximeta_driver_NDASCommand *)fCommandArray->getObject(0);
fCommandArray->removeObject(0);
if( 0 < fCommandArray->getCount() ) {
// Notify to the worker thread.
semaphore_signal(fCommandSema);
}
}
break;
default:
DbgIOLog(DEBUG_MASK_NDAS_ERROR, ("Invalid Command!!! %d\n", (int)newRequest));
return kIOReturnInvalid;
}
return kIOReturnSuccess;
}
开发者ID:dansdrivers,项目名称:ndas4mac,代码行数:48,代码来源:NDASDiskArrayController.cpp
示例9: bounded_buffer_take
/*
* Get an integer from the buffer. Yield control to another
* thread if the buffer is empty.
*/
void bounded_buffer_take(BoundedBuffer *bufp, BufferElem *elem) {
/* Not taking until the queue is known to not be empty */
semaphore_wait(bufp->empty_sema);
/* Accessing the mutex semaphore, to ensure only one thread is running */
semaphore_wait(bufp->single_sema);
/* Copy the element from the buffer, and clear the record */
*elem = bufp->buffer[bufp->first];
bufp->buffer[bufp->first] = empty;
bufp->count--;
bufp->first = (bufp->first + 1) % bufp->length;
/* Signaling that this thread is done with the buffer */
semaphore_signal(bufp->single_sema);
/* Incrementing the full sema */
semaphore_signal(bufp->full_sema);
}
开发者ID:averymarshall,项目名称:projects,代码行数:20,代码来源:bounded_buffer.c
示例10: MACH_CHECK
void Threading::Semaphore::Post(int multiple)
{
for (int i = 0; i < multiple; ++i) {
MACH_CHECK(semaphore_signal(m_sema));
}
__atomic_add_fetch(&m_counter, multiple, __ATOMIC_SEQ_CST);
}
开发者ID:Aced14,项目名称:pcsx2,代码行数:7,代码来源:DarwinSemaphore.cpp
示例11: os_sem_post
void
os_sem_post(os_sem_t *sem, char *what)
{
if (KERN_SUCCESS!=semaphore_signal(*sem))
lose("%s: os_sem_post(%p): %s", what, sem, strerror(errno));
FSHOW((stderr, "%s: os_sem_post(%p) ok\n", what, sem));
}
开发者ID:jsnell,项目名称:sbcl,代码行数:7,代码来源:darwin-os.c
示例12: ReceiveEvtVSync
static void ReceiveEvtVSync (STEVT_CallReason_t Reason,
const ST_DeviceName_t RegistrantName,
STEVT_EventConstant_t Event,
const void *EventData,
const void *SubscriberData_p )
{
STVTG_VSYNC_t EventType;
EventType = *((STVTG_VSYNC_t*)EventData);
switch (EventType)
{
case STVTG_TOP:
stlayer_osd_context.stosd_ActiveTopNotBottom = TRUE;
break;
case STVTG_BOTTOM:
stlayer_osd_context.stosd_ActiveTopNotBottom = FALSE;
break;
default :
break;
}
if ((stlayer_osd_context.UpdateTop)
|| (stlayer_osd_context.UpdateBottom))
{
semaphore_signal(stlayer_osd_context.stosd_VSync_p);
}
}
开发者ID:henrryhe,项目名称:beijing-7101,代码行数:28,代码来源:osd_task.c
示例13: throw
void RBSemaphore::Signal() throw(RBException)
{
mValue.Decrement();
int errorCode = semaphore_signal(mMachSemaphore);
RBAssertNoErr(errorCode, CFSTR("semaphore_signal failed with error code %d"), errorCode);
}
开发者ID:decarbonization,项目名称:PlayerKit,代码行数:7,代码来源:RBAtomic.cpp
示例14: merror
void HighPrecisionClock::runLoop() {
if (!(MachThreadSelf("MWorks High Precision Clock").setRealtime(period, computation, period))) {
merror(M_SCHEDULER_MESSAGE_DOMAIN, "HighPrecisionClock failed to achieve real time scheduling");
}
uint64_t startTime = mach_absolute_time();
while (true) {
{
lock_guard lock(waitsMutex);
while (!waits.empty() && waits.top().getExpirationTime() <= startTime) {
logMachError("semaphore_signal", semaphore_signal(waits.top().getSemaphore()));
waits.pop();
}
}
// Give another thread a chance to terminate this one
boost::this_thread::interruption_point();
// Sleep until the next work cycle
startTime += period;
if (mach_absolute_time() < startTime) {
logMachError("mach_wait_until", mach_wait_until(startTime));
}
}
}
开发者ID:mworks,项目名称:mworks,代码行数:26,代码来源:HighPrecisionClock.cpp
示例15: semaphore_wait
void *Consumer(void *arg)
{
int fd, hit=0;
for (;;) {
#if ApplePositive
semaphore_wait(shared.full);
#else
sem_wait(&shared.full);
#endif
pthread_mutex_lock(&shared.mutex);
fd = shared.buff[shared.out];
shared.buff[shared.out] = 0;
shared.out = (shared.out+1)%shared.buffSize;
/* Release the buffer */
pthread_mutex_unlock(&shared.mutex);
ftp(fd, hit);
/* Increment the number of full slots */
#if ApplePositive
semaphore_signal(shared.empty);
#else
sem_post(&shared.empty);
#endif
hit++;
}
return NULL;
}
开发者ID:rafaelcpalmeida,项目名称:TFTP,代码行数:27,代码来源:tftps.c
示例16: _dispatch_semaphore_signal_slow
DISPATCH_NOINLINE
long
_dispatch_semaphore_signal_slow(dispatch_semaphore_t dsema)
{
// Before dsema_sent_ksignals is incremented we can rely on the reference
// held by the waiter. However, once this value is incremented the waiter
// may return between the atomic increment and the semaphore_signal(),
// therefore an explicit reference must be held in order to safely access
// dsema after the atomic increment.
_dispatch_retain(dsema);
(void)dispatch_atomic_inc2o(dsema, dsema_sent_ksignals);
#if USE_MACH_SEM
_dispatch_semaphore_create_port(&dsema->dsema_port);
kern_return_t kr = semaphore_signal(dsema->dsema_port);
DISPATCH_SEMAPHORE_VERIFY_KR(kr);
#elif USE_POSIX_SEM
int ret = sem_post(&dsema->dsema_sem);
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
#endif
_dispatch_release(dsema);
return 1;
}
开发者ID:PSPDFKit-labs,项目名称:libdispatch,代码行数:25,代码来源:semaphore.c
示例17: pthread_cond_broadcast
/*
* Signal a condition variable, waking up all threads waiting for it.
*/
int
pthread_cond_broadcast(pthread_cond_t *cond)
{
kern_return_t kern_res;
if (cond->sig == _PTHREAD_COND_SIG_init)
{
int res;
if (res = pthread_cond_init(cond, NULL))
return (res);
}
if (cond->sig == _PTHREAD_COND_SIG)
{
LOCK(cond->lock);
if (cond->waiters == 0)
{ /* Avoid kernel call since there are no waiters... */
UNLOCK(cond->lock);
return (ESUCCESS);
}
UNLOCK(cond->lock);
MACH_CALL(semaphore_signal(cond->sem), kern_res);
MACH_CALL(semaphore_signal_all(cond->sem), kern_res);
if (kern_res == KERN_SUCCESS)
{
return (ESUCCESS);
} else
{
return (EINVAL);
}
} else
return (EINVAL); /* Not a condition variable */
}
开发者ID:rohsaini,项目名称:mkunity,代码行数:34,代码来源:pthread_cond.c
示例18:
int XLinuxTask_preemptive::SemWrapper::Post()
{
kern_return_t kres=semaphore_signal(fSem);
xbox_assert(kres==KERN_SUCCESS);
return static_cast<int>(kres);
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:7,代码来源:XLinuxTask.cpp
示例19: handler
void handler ()
{
printf("%s:%d - %s, name [%s]\n", __FILE__, __LINE__, __FUNCTION__, handlerName);
int i;
for(i=0; i < 5; i++)
{
/* If you remove this protection, you should be able to see different
* out of every time you run this program. With this protection, you
* should always be able to see result to be 151402.656521 */
semaphore_wait(counter_mutex); /* down semaphore */
/* START CRITICAL REGION */
/*
int j;
for (j = 0; j < 1000; j++) {
result = result + sin(counter) * tan(counter);
}
*/
result += counter;
counter++;
// sleep(1);
/* END CRITICAL REGION */
semaphore_signal(counter_mutex); /* up semaphore */
}
exit_my_thread(); /* exit thread */
}
开发者ID:iliaden,项目名称:OS-class,代码行数:29,代码来源:sem-ex.c
示例20: monitor_cond_signal
/**
* Signals a monitor condition variable.
* cond is the zero based index of the condition variable which
* must be less than the number of condition variables the monitor
* was created with.
*/
void monitor_cond_signal(monitor_t *monitor, int cond) {
if (monitor->x_count[cond] > 0) {
monitor->next_count++;
semaphore_signal(monitor->sem_id, MONITOR_SEM_COUNT + cond);
semaphore_wait(monitor->sem_id, NEXT_SEM);
monitor->next_count--;
}
}
开发者ID:gundermanc,项目名称:eeccs398-os-and-concurrency,代码行数:14,代码来源:monitor.c
注:本文中的semaphore_signal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论