本文整理汇总了C++中dr_mutex_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ dr_mutex_unlock函数的具体用法?C++ dr_mutex_unlock怎么用?C++ dr_mutex_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dr_mutex_unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hashtable_add
bool
hashtable_add(hashtable_t *table, void *key, void *payload)
{
uint hindex = hash_key(table, key);
hash_entry_t *e;
/* if payload is null can't tell from lookup miss */
ASSERT(payload != NULL, "hashtable_add internal error");
if (table->synch)
dr_mutex_lock(table->lock);
for (e = table->table[hindex]; e != NULL; e = e->next) {
if (keys_equal(table, e->key, key)) {
/* we have a use where payload != existing entry so we don't assert on that */
if (table->synch)
dr_mutex_unlock(table->lock);
return false;
}
}
e = (hash_entry_t *) hash_alloc(sizeof(*e));
if (table->str_dup) {
const char *s = (const char *) key;
e->key = hash_alloc(strlen(s)+1);
strncpy((char *)e->key, s, strlen(s)+1);
} else
e->key = key;
e->payload = payload;
e->next = table->table[hindex];
table->table[hindex] = e;
table->entries++;
hashtable_check_for_resize(table);
if (table->synch)
dr_mutex_unlock(table->lock);
return true;
}
示例2: event_basic_block
static dr_emit_flags_t
event_basic_block(void *drcontext, void *tag, instrlist_t *bb, bool for_trace, bool translating)
{
instr_t *instr;
trace_head_entry_t *e = NULL;
if (translating)
return DR_EMIT_DEFAULT;
for (instr = instrlist_first(bb); instr != NULL; instr = instr_get_next(instr)) {
/* blocks containing calls are trace heads */
if (instr_is_call(instr)) {
dr_mark_trace_head(drcontext, tag);
dr_mutex_lock(htable_mutex);
e = add_trace_head_entry(NULL, tag);
e->is_trace_head = true;
dr_mutex_unlock(htable_mutex);
#ifdef VERBOSE
dr_log(drcontext, LOG_ALL, 3,
"inline: marking bb "PFX" as trace head\n", tag);
#endif
/* doesn't matter what's in rest of bb */
return DR_EMIT_DEFAULT;
} else if (instr_is_return(instr)) {
dr_mutex_lock(htable_mutex);
e = add_trace_head_entry(NULL, tag);
e->has_ret = true;
dr_mutex_unlock(htable_mutex);
}
}
return DR_EMIT_DEFAULT;
}
示例3: init_context
/* Annotation handler to initialize a client context (associated with an app thread) */
static void
init_context(uint id, const char *label, uint initial_mode)
{
context_t *context;
dr_mutex_lock(context_lock);
PRINTF("Initialize context %d '%s' in mode %d", id, label, initial_mode);
context = get_context(id);
if (context == NULL) {
uint label_length = (uint) (sizeof(char) * strlen(label)) + 1;
context = dr_global_alloc(sizeof(context_t));
context->id = id;
context->label = dr_global_alloc(label_length);
context->mode = initial_mode;
context->mode_history = dr_global_alloc(MAX_MODE_HISTORY * sizeof(uint));
context->mode_history[0] = initial_mode;
context->mode_history_index = 1;
memcpy(context->label, label, label_length);
context->next = NULL;
if (context_list->head == NULL) {
context_list->head = context_list->tail = context;
} else {
context_list->tail->next = context;
context_list->tail = context;
}
}
dr_mutex_unlock(context_lock);
}
示例4: post_malloc
void post_malloc(void *wrapctx, void *user_data)
{
malloc_t *block = (malloc_t *)user_data;
dr_mutex_lock(lock);
if (!block)
{
dr_mutex_unlock(lock);
return;
}
set_addr_malloc(block, drwrap_get_retval(wrapctx), ALLOC, 0);
dr_mutex_unlock(lock);
}
示例5: drmgr_exit
DR_EXPORT
void
drmgr_exit(void)
{
static bool exited;
/* try to handle multiple calls to exit. still possible to crash
* trying to lock a destroyed lock.
*/
if (exited || !dr_mutex_trylock(exit_lock) || exited)
return;
exited = true;
drmgr_bb_exit();
drmgr_event_exit();
dr_rwlock_destroy(presys_event_lock);
dr_rwlock_destroy(cls_event_lock);
dr_mutex_destroy(tls_lock);
dr_rwlock_destroy(thread_event_lock);
dr_rwlock_destroy(bb_cb_lock);
dr_mutex_destroy(note_lock);
dr_mutex_unlock(exit_lock);
dr_mutex_destroy(exit_lock);
}
示例6: hashtable_delete
void
hashtable_delete(hashtable_t *table)
{
uint i;
if (table->synch)
dr_mutex_lock(table->lock);
for (i = 0; i < HASHTABLE_SIZE(table->table_bits); i++) {
hash_entry_t *e = table->table[i];
while (e != NULL) {
hash_entry_t *nexte = e->next;
if (table->str_dup)
hash_free(e->key, strlen((const char *)e->key) + 1);
if (table->free_payload_func != NULL)
(table->free_payload_func)(e->payload);
hash_free(e, sizeof(*e));
e = nexte;
}
}
hash_free(table->table, (size_t)HASHTABLE_SIZE(table->table_bits) *
sizeof(hash_entry_t*));
table->table = NULL;
table->entries = 0;
if (table->synch)
dr_mutex_unlock(table->lock);
dr_mutex_destroy(table->lock);
}
示例7: add_hit
void add_hit(void *pc, size_t size, void *target, int read, void *drcontext,
ctx_t *ctx)
{
malloc_t *block = search_on_tree(active_blocks, target);
access_t *access;
// if the access is not on a malloc block we do nothing
// we have to check if the target is not the and of the block
// (because last offset is out of the user
// data and use only for malloc's internal purposes)
if (!block || target == block->end)
return;
dr_mutex_lock(lock);
if (read)
access = get_access(target - block->start, &(block->read), block);
else
access = get_access(target - block->start, &(block->write), block);
access->total_hits++;
incr_orig(access, size, pc, drcontext, block, ctx);
dr_mutex_unlock(lock);
}
示例8: instrace_thread_exit
void
instrace_thread_exit(void *drcontext)
{
per_thread_t *data;
int i;
if (client_arg->instrace_mode == INS_TRACE){
ins_trace(drcontext);
}
data = drmgr_get_tls_field(drcontext, tls_index);
dr_mutex_lock(mutex);
num_refs += data->num_refs;
dr_mutex_unlock(mutex);
dr_close_file(data->outfile);
if (log_mode){
dr_close_file(data->logfile);
}
dr_thread_free(drcontext, data->buf_base, INSTR_BUF_SIZE);
dr_thread_free(drcontext, data->output_array, OUTPUT_BUF_SIZE);
DEBUG_PRINT("%s - thread id : %d, cloned instructions freeing now - %d\n",ins_pass_name, dr_get_thread_id(drcontext),data->static_ptr);
for(i=0 ; i<data->static_ptr; i++){
instr_destroy(dr_get_current_drcontext(),data->static_array[i]);
}
dr_thread_free(drcontext, data->static_array, sizeof(instr_t *)*client_arg->static_info_size);
dr_thread_free(drcontext, data, sizeof(per_thread_t));
DEBUG_PRINT("%s - exiting thread done %d\n", ins_pass_name, dr_get_thread_id(drcontext));
}
示例9: event_fragment_deleted
/* to keep the size of our hashtable down */
static void
event_fragment_deleted(void *drcontext, void *tag)
{
dr_mutex_lock(htable_mutex);
remove_trace_head_entry(NULL, tag);
dr_mutex_unlock(htable_mutex);
}
示例10: drvector_delete
bool
drvector_delete(drvector_t *vec)
{
uint i;
if (vec == NULL)
return false;
if (vec->synch)
dr_mutex_lock(vec->lock);
/* Since we lazily initialize the array, vec->array could be NULL if we
* called drvector_init with capacity 0 and never inserted an element into
* the vec. We check vec->array here and below before access.
* */
if (vec->free_data_func != NULL && vec->array != NULL) {
for (i = 0; i < vec->entries; i++) {
(vec->free_data_func)(vec->array[i]);
}
}
if (vec->array != NULL) {
dr_global_free(vec->array, vec->capacity * sizeof(void *));
vec->array = NULL;
vec->entries = 0;
}
if (vec->synch)
dr_mutex_unlock(vec->lock);
dr_mutex_destroy(vec->lock);
return true;
}
示例11: inc_count_second
static void
inc_count_second(int second)
{
dr_mutex_lock(mutex);
counts[second]++;
dr_mutex_unlock(mutex);
}
示例12: hashtable_remove
bool
hashtable_remove(hashtable_t *table, void *key)
{
bool res = false;
hash_entry_t *e, *prev_e;
uint hindex = hash_key(table, key);
if (table->synch)
dr_mutex_lock(table->lock);
for (e = table->table[hindex], prev_e = NULL; e != NULL; prev_e = e, e = e->next) {
if (keys_equal(table, e->key, key)) {
if (prev_e == NULL)
table->table[hindex] = e->next;
else
prev_e->next = e->next;
if (table->str_dup)
hash_free(e->key, strlen((const char *)e->key) + 1);
if (table->free_payload_func != NULL)
(table->free_payload_func)(e->payload);
hash_free(e, sizeof(*e));
res = true;
table->entries--;
break;
}
}
if (table->synch)
dr_mutex_unlock(table->lock);
return res;
}
示例13: ordered_lock
static inline void
ordered_lock(ipc_channel_t *channel, uint tid)
{
dr_mutex_lock(channel->queue_lock);
ticket_queue_t *q = &channel->ticket_queue;
if (q->locked)
{
ticket_node_t *node = dr_global_alloc(sizeof(ticket_node_t));
if (node == NULL)
DR_ABORT_MSG("Failed to allocate ticket node\n");
node->next = NULL;
node->dr_event = dr_event_create();
node->waiting = true;
node->thread_id = tid;
DR_ASSERT(q->tail->next == NULL);
q->tail = q->tail->next = node;
SGL_DEBUG("Sleeping Thread :%d\n", tid);
dr_mutex_unlock(channel->queue_lock);
/* MDL20170425 TODO(soonish)
* how likely is it that we'll miss a wakeup here? */
while (node->waiting)
dr_event_wait(node->dr_event);
dr_mutex_lock(channel->queue_lock);
q->head->next = node->next;
if (q->tail == node)
q->tail = q->head;
dr_event_destroy(node->dr_event);
dr_global_free(node, sizeof(ticket_node_t));
SGL_DEBUG("Awakened Thread :%d\n", tid);
}
else
{
q->locked = true;
}
dr_mutex_unlock(channel->queue_lock);
}
示例14: inc_count_first
static void
inc_count_first(int first, int second)
{
dr_mutex_lock(mutex);
if (counts[second] == 0)
dr_fprintf(STDERR, "%s is called before %s\n", name[first], name[second]);
counts[first]++;
dr_mutex_unlock(mutex);
}
示例15: delete_fragment
static void
delete_fragment(void *drcontext, app_pc tag)
{
dr_mutex_lock(mutex);
deletions++;
dr_mutex_unlock(mutex);
dr_delete_fragment(drcontext, tag);
}