本文整理汇总了C++中cond_signal函数的典型用法代码示例。如果您正苦于以下问题:C++ cond_signal函数的具体用法?C++ cond_signal怎么用?C++ cond_signal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cond_signal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rpc_ctx_ack_xfer
void
rpc_ctx_ack_xfer(rpc_ctx_t *ctx)
{
struct x_vc_data *xd = (struct x_vc_data *) ctx->ctx_u.clnt.clnt->cl_p1;
rpc_dplx_lock_t *lk = &xd->rec->recv.lock;
ctx->flags |= RPC_CTX_FLAG_ACKSYNC;
cond_signal(&lk->we.cv); /* XXX we hold lk->we.mtx */
}
示例2: worker_multistep_transfer_request
void worker_multistep_transfer_request(Worker *worker,
void (*func)(Worker *, void *), void *arg)
{
assert(worker->func == NULL);
assert(worker->arg == NULL);
worker->func = func;
worker->arg = arg;
cond_signal(worker->sleep);
}
示例3: sync1_action
static void
sync1_action()
{
if (fetch_sub(relaxed, &sync_counter, 1) - 1 == 0) {
mutex_lock(&sync_wait_lock);
cond_signal(&sync_wait_cond);
mutex_unlock(&sync_wait_lock);
}
}
示例4: cond_broadcast
/* Wakes up all threads, if any, waiting on COND (protected by
LOCK). LOCK must be held before calling this function.
An interrupt handler cannot acquire a lock, so it does not
make sense to try to signal a condition variable within an
interrupt handler. */
void
cond_broadcast (struct condition *cond, struct lock *lock)
{
ASSERT (cond != NULL);
ASSERT (lock != NULL);
while (!list_empty (&cond->waiters))
cond_signal (cond, lock);
}
示例5: incr_semaphore
/* Increments the semaphore */
void incr_semaphore(Semaphore *semaphore) {
mutex_lock(semaphore->mutex);
printf("PLUS-----%d\n", semaphore->value);
semaphore->value++;
printf("PLUS-----%d\n", semaphore->value);
mutex_unlock(semaphore->mutex);
if (semaphore->value == 1)
cond_signal(semaphore->cond);
}
示例6: force_media
/*
* force_media - unload a drive. Issued as a delayed request.
*
*/
req_comp_t
force_media(
library_t *library,
drive_state_t *drive)
{
req_comp_t err;
ibm_req_info_t *ibm_info;
robo_event_t *force, *tmp;
xport_state_t *transport;
ibm_info = (ibm_req_info_t *)malloc_wait(sizeof (ibm_req_info_t), 2, 0);
memset(ibm_info, 0, sizeof (ibm_req_info_t));
ibm_info->drive_id = drive->drive_id;
/* Build transport thread request */
force = malloc_wait(sizeof (robo_event_t), 5, 0);
(void) memset(force, 0, sizeof (robo_event_t));
force->request.internal.command = ROBOT_INTRL_FORCE_MEDIA;
force->request.internal.address = (void *)ibm_info;
if (DBG_LVL(SAM_DBG_TMOVE))
sam_syslog(LOG_DEBUG, "force_media: from %s.", drive->un->name);
force->type = EVENT_TYPE_INTERNAL;
force->status.bits = REST_SIGNAL;
force->completion = REQUEST_NOT_COMPLETE;
transport = library->transports;
mutex_lock(&force->mutex);
mutex_lock(&transport->list_mutex);
if (transport->active_count == 0)
transport->first = force;
else {
LISTEND(transport, tmp);
append_list(tmp, force);
}
transport->active_count++;
cond_signal(&transport->list_condit);
mutex_unlock(&transport->list_mutex);
/* Wait for the transport to do the unload */
while (force->completion == REQUEST_NOT_COMPLETE)
cond_wait(&force->condit, &force->mutex);
mutex_unlock(&force->mutex);
err = (req_comp_t)force->completion;
if (DBG_LVL(SAM_DBG_TMOVE))
sam_syslog(LOG_DEBUG,
"Return from transport force (%#x).", force->completion);
free(ibm_info);
mutex_destroy(&force->mutex);
free(force);
return (err);
}
示例7: phi_test_condvar
void phi_test_condvar (i) {
if(state_condvar[i]==HUNGRY&&state_condvar[LEFT]!=EATING
&&state_condvar[RIGHT]!=EATING) {
cprintf("phi_test_condvar: state_condvar[%d] will eating\n",i);
state_condvar[i] = EATING ;
cprintf("phi_test_condvar: signal self_cv[%d] \n",i);
cond_signal(&mtp->cv[i]) ;
}
}
示例8: bounded_buffer_put
void bounded_buffer_put(bounded_buffer_t *b, void* ptr) {
mutex_lock(&b->mutex);
while (b->count == b->size)
cond_wait(&b->empty, &b->mutex);
b->buffer[b->tail] = ptr;
b->tail = (b->tail + 1) % b->size;
b->count++;
cond_signal(&b->fill);
mutex_unlock(&b->mutex);
}
示例9: sl_append
void sl_append(struct SynchList *sl, void *item)
{
lock_acquire(&sl->sl_lock); // enforce mutual exclusive access to the list
struct SL_element *sl_elem = malloc(sizeof(struct SL_element));
sl_elem->item = item;
list_push_back(&sl->sl_list, &sl_elem->elem);
cond_signal(&sl->sl_empty,&sl->sl_lock); // wake up a waiter, if any
lock_release(&sl->sl_lock);
return;
}
示例10: cache_shared_post
void cache_shared_post(struct cache_block * curr_block, uint8_t dirty) {
lock_acquire(&curr_block->modify_variables);
curr_block->accessors--;
curr_block->use = 1;
if (dirty) {
curr_block->dirty = dirty;
}
cond_signal(&curr_block->need_to_evict, &curr_block->modify_variables);
lock_release(&curr_block->modify_variables);
}
示例11: sem_signal
void sem_signal (Semaphore *semaphore) {
mutex_lock (semaphore->mutex);
semaphore->value++;
if (semaphore->value <= 0) {
semaphore->wakeups++;
cond_signal (semaphore->cond);
}
mutex_unlock (semaphore->mutex);
}
示例12: set_state
/*
* set new state for a device.
*
* Programming note: The parameter passed in was malloc'ed, be sure
* to free it before thr_exit.
*/
void *
set_state(
void *vcmd)
{
int old_state;
sam_cmd_fifo_t *command = (sam_cmd_fifo_t *)vcmd;
dev_ent_t *device, *robot = NULL;
message_request_t *message = NULL;
/* equipment was verified in the caller */
device = DEV_ENT(command->eq);
if (device->fseq) {
robot = DEV_ENT(device->fseq);
}
if (command->state >= DEV_ON && command->state <= DEV_DOWN &&
command->state != DEV_NOALLOC) {
old_state = device->state;
if (robot != NULL) {
device = robot;
if (IS_ROBOT(device) && device->status.b.present) {
message = (message_request_t *)SHM_REF_ADDR(
device->dt.rb.message);
}
} else if (IS_OPTICAL(device) || IS_TAPE(device)) {
/* send to scanner */
message = (message_request_t *)SHM_REF_ADDR(
((shm_ptr_tbl_t *)master_shm.shared_memory)->
scan_mess);
}
if (message != NULL) {
(void) mutex_lock(&message->mutex);
while (message->mtype != MESS_MT_VOID) {
cond_wait(&message->cond_i, &message->mutex);
}
memset(&message->message, 0, sizeof (sam_message_t));
message->message.magic = MESSAGE_MAGIC;
message->message.command = MESS_CMD_STATE;
message->message.exit_id = command->exit_id;
message->message.param.state_change.flags =
command->flags;
message->message.param.state_change.eq = command->eq;
message->message.param.state_change.old_state =
old_state;
message->message.param.state_change.state =
command->state;
message->mtype = MESS_MT_NORMAL;
cond_signal(&message->cond_r);
mutex_unlock(&message->mutex);
}
}
free(command); /* free the command buffer */
thr_exit(NULL);
/* LINTED Function has no return statement */
}
示例13: worker_wake
/*===========================================================================*
* worker_wake *
*===========================================================================*/
PRIVATE void worker_wake(struct worker_thread *worker)
{
/* Signal a worker to wake up */
ASSERTW(worker);
if (mutex_lock(&worker->w_event_mutex) != 0)
panic("unable to lock event mutex");
if (cond_signal(&worker->w_event) != 0)
panic("unable to signal conditional variable");
if (mutex_unlock(&worker->w_event_mutex) != 0)
panic("unable to unlock event mutex");
}
示例14: control_leave
static void
control_leave(struct sml_control *control)
{
assert(load_relaxed(&control->state) == ACTIVE(ASYNC));
/* unlock; all updates so far must be released */
store_release(&control->state, INACTIVE(ASYNC));
if (load_relaxed(&stop_the_world_flag)) {
mutex_lock(&control->inactive_wait_lock);
cond_signal(&control->inactive_wait_cond);
mutex_unlock(&control->inactive_wait_lock);
}
}
示例15: add_catalog_cmd
/*
* add catalog command
*
* Programming note: The parameter passed in was malloc'ed, be sure
* to free it before thr_exit.
*/
void *
add_catalog_cmd(
void *vcmd)
{
sam_cmd_fifo_t *command = (sam_cmd_fifo_t *)vcmd;
dev_ent_t *device;
message_request_t *message;
if (command->vsn[0] == '\0' && !(command->flags & ADDCAT_BARCODE)) {
sam_syslog(LOG_INFO,
catgets(catfd, SET, 11008,
"Add catalog, vsn not supplied."));
} else {
device = DEV_ENT(DEV_ENT(command->eq)->fseq);
if ((IS_GENERIC_API(device->type) ||
device->type == DT_STKAPI ||
device->type == DT_SONYPSC ||
device->type == DT_IBMATL) ||
device->type == DT_HISTORIAN &&
(device->state < DEV_IDLE) &&
(device->status.b.ready && device->status.b.present)) {
message = (message_request_t *)
SHM_REF_ADDR(device->dt.rb.message);
(void) mutex_lock(&message->mutex);
while (message->mtype != MESS_MT_VOID) {
cond_wait(&message->cond_i, &message->mutex);
}
memset(&message->message, 0, sizeof (sam_message_t));
message->message.magic = MESSAGE_MAGIC;
message->message.command = MESS_CMD_ADD;
message->message.exit_id = command->exit_id;
message->mtype = MESS_MT_NORMAL;
message->message.param.addcat_request.media =
command->media;
message->message.param.addcat_request.flags =
command->flags;
memmove(&message->message.param.addcat_request.vsn[0],
&command->vsn[0], sizeof (vsn_t));
if (command->flags & ADDCAT_BARCODE) {
memccpy(&message->
message.param.addcat_request.bar_code[0],
&command->info[0], '\0', BARCODE_LEN);
}
cond_signal(&message->cond_r);
mutex_unlock(&message->mutex);
}
}
free(command); /* free the command buffer */
thr_exit(NULL);
/* LINTED Function has no return statement */
}