本文整理汇总了C++中cond_signal函数的典型用法代码示例。如果您正苦于以下问题:C++ cond_signal函数的具体用法?C++ cond_signal怎么用?C++ cond_signal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cond_signal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 */
}
开发者ID:bongiojp,项目名称:libtirpc-lbx,代码行数:9,代码来源:rpc_ctx.c
示例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);
}
开发者ID:russross,项目名称:envoy,代码行数:9,代码来源:worker.c
示例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);
}
}
开发者ID:eldesh,项目名称:smlsharp,代码行数:9,代码来源:control.c
示例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);
}
开发者ID:ITSophia,项目名称:Pintos,代码行数:15,代码来源:synch.c
示例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);
}
开发者ID:jgibson5,项目名称:Olin,代码行数:10,代码来源:semaphore.c
示例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);
}
开发者ID:BackupTheBerlios,项目名称:samqfs,代码行数:61,代码来源:media_move.c
示例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]) ;
}
}
开发者ID:Silver-Shen,项目名称:OS_LAB,代码行数:9,代码来源:check_sync.c
示例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);
}
开发者ID:malichan,项目名称:cs537-project,代码行数:10,代码来源:crawler.c
示例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;
}
开发者ID:Argabarga,项目名称:Wololol,代码行数:10,代码来源:synchlist.c
示例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);
}
开发者ID:tonychenr,项目名称:CS162-group34,代码行数:10,代码来源:cache.c
示例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);
}
开发者ID:ElizabethDuncan,项目名称:SoftwareSystemsClass,代码行数:10,代码来源:semaphore.c
示例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 */
}
开发者ID:BackupTheBerlios,项目名称:samqfs,代码行数:61,代码来源:fifo_cmds.c
示例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");
}
开发者ID:vivekp,项目名称:minix-1,代码行数:14,代码来源:worker.c
示例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);
}
}
开发者ID:eldesh,项目名称:smlsharp,代码行数:12,代码来源:control.c
示例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 */
}
开发者ID:BackupTheBerlios,项目名称:samqfs,代码行数:58,代码来源:fifo_cmds.c
示例16: unbounded_buffer_put
void unbounded_buffer_put(unbounded_buffer_t *b, void *ptr) {
node_t *node = (node_t *)mem_malloc(sizeof(node_t));
node->ptr = ptr;
node->next = NULL;
mutex_lock(&b->tail_mutex);
b->tail->next = node;
b->tail = node;
mutex_lock(&b->mutex);
mutex_unlock(&b->tail_mutex);
b->count++;
cond_signal(&b->fill);
mutex_unlock(&b->mutex);
}
开发者ID:malichan,项目名称:cs537-project,代码行数:13,代码来源:crawler.c
示例17: slp_end_call
void slp_end_call(slp_handle_impl_t *hp) {
(void) mutex_lock(&(hp->outcall_lock));
if (hp->close_on_end) {
/* SLPClose() called from callback */
(void) mutex_unlock(&(hp->outcall_lock));
slp_cleanup_handle(hp);
return;
}
hp->pending_outcall = SLP_FALSE;
(void) cond_signal(&(hp->outcall_cv));
(void) mutex_unlock(&(hp->outcall_lock));
}
开发者ID:andreiw,项目名称:polaris,代码行数:13,代码来源:slp_utils.c
示例18: fifoproc_release
/*
*Cierra un /proc en el modo especificado por el parametro de entrada
*bool lectura ==> 1 cierra en modo lectura, 0 cierra en modo escritura
*/
void fifoproc_release(bool lectura) {
lock(mtx);
/*Si queremos cerrar un fichero en modo lectura, reducimos
*el numero de consumidores en una unidad y, en caso de que
*ya no existan productores, limpiamos el buffer*/
if(lectura) {
cons_count--;
cond_signal(prod);
}
/*Si queremos cerrar un fichero en modo escritura, reducimos
*el numero de productores en una unidad y, en caso de que
*ya no existan consumidores, limpiamos el buffer*/
else {
prod_count--;
cond_signal(cons);
}
if((prod_count ==0) && (cons_count ==0))
clear_cbuffer_t(cbuffer);
unlock(mtx);
}
开发者ID:densypko,项目名称:UCM-LIN,代码行数:26,代码来源:pseudocodigo.c
示例19: while
/* Child process monitoring function */
void *process_monitor() {
pid_t child_pid; /* pid of zombie child */
int status, time_interval; /* child exit status; interval between time_t's */
while(true) {
mutex_lock(&g_mutex);
if(g_num_children > 0) {
mutex_unlock(&g_mutex);
child_pid = wait(&status);
if(child_pid < 0) {
if(errno == EINTR) /* Waiting interrupted */
continue;
else
handle_error("wait");
}
mutex_lock(&g_mutex);
time_interval = update_terminated_process(g_lst_children,
child_pid, status, time(NULL));
if(time_interval < 0) {
fprintf(stderr, "update_terminated_process: interval is negative\n");
fprintf(stderr, "Not logging process %d..\n", child_pid);
} else {
g_total_time += time_interval;
fprintf(g_log_file, "iteracao %d\n" \
"PID: %d execution time: %02d s\n" \
"total execution time: %02d s\n",
g_iterations++, child_pid, time_interval, g_total_time);
f_flush(g_log_file);
}
--g_num_children;
cond_signal(&g_child_cv);
mutex_unlock(&g_mutex);
} else if(g_monitoring) {
while(g_num_children == 0 && g_monitoring)
cond_wait(&g_monitoring_cv, &g_mutex);
mutex_unlock(&g_mutex);
}
else break;
}
mutex_unlock(&g_mutex);
return NULL;
}
开发者ID:RGCV,项目名称:SO1516-ParShell,代码行数:52,代码来源:par-shell.c
示例20: lxt_server_loop
static void
lxt_server_loop(void)
{
lxt_req_t *lxt_req;
lxt_server_arg_t *request;
size_t request_size;
char *door_result;
size_t door_result_size;
for (;;) {
/* Wait for a request from a doors server thread. */
(void) mutex_lock(&lxt_req_lock);
while (lxt_req_ptr == NULL)
(void) cond_wait(&lxt_req_cv, &lxt_req_lock);
/* We got a request, get a local pointer to it. */
lxt_req = lxt_req_ptr;
lxt_req_ptr = NULL;
(void) cond_broadcast(&lxt_req_cv);
(void) mutex_unlock(&lxt_req_lock);
/* Get a pointer to the request. */
request = lxt_req->lxtr_request;
request_size = lxt_req->lxtr_request_size;
lx_debug("lxt_server_loop: Linux thread request recieved, "
"request = %p", request);
/* Dispatch the request. */
assert((request->lxt_sa_op > LXT_SERVER_OP_PING) ||
(request->lxt_sa_op < LXT_SERVER_OP_MAX));
lxt_operations[request->lxt_sa_op].lxto_fp(
request, request_size, &door_result, &door_result_size);
lx_debug("lxt_server_loop: Linux thread request completed, "
"request = %p", request);
(void) mutex_lock(&lxt_req_lock);
/* Set the result pointers for the calling door thread. */
lxt_req->lxtr_result = door_result;
lxt_req->lxtr_result_size = door_result_size;
/* Let the door thread know we're done. */
lxt_req->lxtr_complete = 1;
(void) cond_signal(&lxt_req->lxtr_complete_cv);
(void) mutex_unlock(&lxt_req_lock);
}
/*NOTREACHED*/
}
开发者ID:maosi66,项目名称:illumos-joyent,代码行数:51,代码来源:lx_thunk_server.c
注:本文中的cond_signal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论