当前位置: 首页>>代码示例>>C++>>正文


C++ pthread_spin_unlock函数代码示例

本文整理汇总了C++中pthread_spin_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ pthread_spin_unlock函数的具体用法?C++ pthread_spin_unlock怎么用?C++ pthread_spin_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pthread_spin_unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: psivhmem_free_frame

int psivhmem_free_frame(ivshmem_pci_dev_t *dev, char * frame_ptr)
{
/*
 * first implementation: just clear corresponding bit in bitmap -> frame is available again
 *
 */
    unsigned long long n;
    unsigned long long index;

    if(!psivshmem_ptr_in_dev(dev, frame_ptr)) return -1;

    index = (frame_ptr - dev->ivshmem_base) / dev->frame_size;

    pthread_spin_lock(dev->spinlock);

	CLR_BIT(dev->bitmap,index);

    pthread_spin_unlock(dev->spinlock);

    return 0;
}
开发者ID:RWTH-OS,项目名称:pscom,代码行数:21,代码来源:psivshmem.c

示例2: pull_buf

void* pull_buf(struct pipe* p, int id, const void** buf, int* seq)
{
	struct pipe_elem* elem = NULL;

	// lock
	pthread_spin_lock(&p->lock);

	if (id < 0 || id >= p->n_dst)
		goto unlock;

	if (!dequeue(&p->dst[id], (void**)&elem)) {
		*buf = elem->buf;
		*seq = elem->seq;
	}

	// unlock
unlock : 
	pthread_spin_unlock(&p->lock);

	return elem;
}
开发者ID:allskyee,项目名称:v4l2_camera_xdisplay,代码行数:21,代码来源:pipe.c

示例3: test_spin3

int
test_spin3(void)
#endif
{
  pthread_t t;

  wasHere = 0;
  assert(pthread_spin_init(&spin, PTHREAD_PROCESS_PRIVATE) == 0);
  assert(pthread_spin_lock(&spin) == 0);
  assert(pthread_create(&t, NULL, unlocker, (void *) 0) == 0);
  assert(pthread_join(t, NULL) == 0);
  /*
   * Our spinlocks don't record the owner thread so any thread can unlock the spinlock,
   * but nor is it an error for any thread to unlock a spinlock that is not locked.
   */
  assert(pthread_spin_unlock(&spin) == 0);
  assert(pthread_spin_destroy(&spin) == 0);
  assert(wasHere == 2);

  return 0;
}
开发者ID:Avic,项目名称:pthread-win32,代码行数:21,代码来源:spin3.c

示例4: pthread_create

int pthread_create(pthread_t* thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void* arg) {
        event_t e;

        pthread_spin_lock(&lock);
       
        VERBOSE("[INTERCEPT] --> pthread_create\n");
       
        /* lock */
        e.owner = hashid.processes[id(pthread_self())];
        e.type = PTHREAD_CREATE;
        fire(&global_table, e);
       
        int ret = _BIANCApthread_create(thread, attr, start_routine, arg);
       
        e.son = id(*thread);
        post_fire(&global_table, e);
        hashid.processes[e.son] = find_process_id(&global_table, e.son);

        pthread_spin_unlock(&lock);
        return ret;
}
开发者ID:SavithaSwaroop,项目名称:Evinrude-CAMI-PNML,代码行数:21,代码来源:spin_capsule.c

示例5: global_cron

//global cron
//delete and close useless tcp fd
int
global_cron(struct server *s)
{
    int fd = -1;
    struct list_node *nds, *tmp;
    struct list *el = &s->eventlist;
    pthread_spin_lock(&el->lock);
    nds = el->head;
    el->head = NULL;
    pthread_spin_unlock(&el->lock);
    while (nds != NULL) {
        fd = *(int *) nds->data;
        if (fd > 0)
            close(fd);
        tmp = nds->next;
        free(nds->data);
        free(nds);
        nds = tmp;
    }
    return 0;
}
开发者ID:cofyc,项目名称:dnspod-sr,代码行数:23,代码来源:author.c

示例6: test_spin2

int
test_spin2(void)
#endif
{
  pthread_t t;

  assert(pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE) == 0);

  assert(pthread_spin_lock(&lock) == 0);

  assert(pthread_create(&t, NULL, func, NULL) == 0);
  assert(pthread_join(t, NULL) == 0);

  assert(pthread_spin_unlock(&lock) == 0);

  assert(pthread_spin_destroy(&lock) == 0);

  assert(washere == 1);

  return 0;
}
开发者ID:DMDZYP,项目名称:pthread-win32,代码行数:21,代码来源:spin2.c

示例7: usdf_pep_grow_backlog

static int
usdf_pep_grow_backlog(struct usdf_pep *pep)
{
    struct usdf_connreq *crp;
    size_t extra;

    extra = sizeof(struct usdf_connreq_msg) + pep->pep_cr_max_data;

    while (pep->pep_cr_alloced < pep->pep_backlog) {
        crp = calloc(1, sizeof(*crp) + extra);
        if (crp == NULL) {
            return -FI_ENOMEM;
        }
        crp->handle.fclass = FI_CLASS_CONNREQ;
        pthread_spin_lock(&pep->pep_cr_lock);
        TAILQ_INSERT_TAIL(&pep->pep_cr_free, crp, cr_link);
        ++pep->pep_cr_alloced;
        pthread_spin_unlock(&pep->pep_cr_lock);
    }
    return 0;
}
开发者ID:chuckfossen,项目名称:libfabric-cray,代码行数:21,代码来源:usdf_pep.c

示例8: ddlog_ext_register_built_in_events

int ddlog_ext_register_built_in_events(void){
    int spin_res = 0;
    int ret = DDLOG_RET_ERR;

    spin_res = pthread_spin_lock(&ddlog_ext_events.lock);
    if (spin_res == 0){
        ddlog_ext_events.events[ddlog_ext_events.index].event_type = DDLOG_EXT_EVENT_TYPE_BT;
        ddlog_ext_events.events[ddlog_ext_events.index].print_callback = ddlog_ext_display_bt;
        ddlog_ext_events.index++;

        ddlog_ext_events.events[ddlog_ext_events.index].event_type = DDLOG_EXT_EVENT_TYPE_HEXDUMP;
        ddlog_ext_events.events[ddlog_ext_events.index].print_callback = ddlog_ext_display_hex_dump;
        ddlog_ext_events.index++;

        spin_res = pthread_spin_unlock(&ddlog_ext_events.lock);
        if (spin_res == 0){
            ret = DDLOG_RET_OK;
        }
    }
    return ret;
}
开发者ID:jozsef-galajda,项目名称:ddlog,代码行数:21,代码来源:ddlog_ext.c

示例9: iohelp_handle_io_release_conch

/* Called by an I/O server upon receipt of an io_release_conch message;
   The user identified by USER is done with conch C; release it and 
   allow a waiting user to obtain the conch.  */
void
iohelp_handle_io_release_conch (struct conch *c, void *user)
{
  struct shared_io *user_sh = c->holder_shared_page;

  pthread_spin_lock (&user_sh->lock);
  if (c->holder_shared_page->conch_status != USER_HAS_NOT_CONCH)
    {
      c->holder_shared_page->conch_status = USER_HAS_NOT_CONCH;
      iohelp_fetch_shared_data (c->holder);
    }
  pthread_spin_unlock (&user_sh->lock);

  if (c->holder == user)
    {
      c->holder = 0;
      c->holder_shared_page = 0;
    }

  pthread_cond_broadcast (&c->wait);
}
开发者ID:GNUHurdTR,项目名称:hurd,代码行数:24,代码来源:handle_io_release_conch.c

示例10: sstack_sfsd_add

inline int
sstack_sfsd_add(uint32_t weight, sstack_sfsd_pool_t *pools,
				sfsd_t *sfsd)
{
	sstack_sfsd_pool_t *temp = NULL;
	int i = 0;
	int index = -1;


	// Parameter validation
	if (weight < MAXIMUM_WEIGHT || weight > MINIMUM_WEIGHT ||
				NULL == pools || NULL == sfsd) {
		sfs_log(sfs_ctx, SFS_ERR, "%s: Invalid parametes specified \n",
						__FUNCTION__);

		errno = EINVAL;
		return -1;
	}

	// Get index of sfsd pool that covers the specified storeg weight
	for (i = 0; i < MAX_SFSD_POOLS; i++) {
		uint32_t low = *(uint32_t *) &weights[i][0];
		uint32_t high = *(uint32_t *) &weights[i][1];
		if (weight >= low && weight <= high)
			break;
	}
	index = i;
	temp = pools;

	for (i = 0; i < index; i++)
		temp ++;

	// Now temp points to the right pool
	pthread_spin_lock(&temp->lock);
	bds_list_add_tail((bds_list_head_t) &sfsd->list,
								(bds_list_head_t) &temp->list);
	pthread_spin_unlock(&temp->lock);

	return 0;
}
开发者ID:shubhros,项目名称:SeamlessStack,代码行数:40,代码来源:sfs_helper.c

示例11: pthread_setcancelstate

// funzione realtiva allo spinlock
void *do_something(long int who_i_am) {
    int i;
    int dummy;

    // imposta la cancellazione asincrona
    pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,&dummy);
    pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,&dummy);

    // aspetta che pure l'altro thread l'abbia fatto
    pthread_barrier_wait(&pbarrier);
    // sblocca il segnale SIGUSR1
    pthread_sigmask(SIG_UNBLOCK,&block_sig,NULL);

    while (1) {
        // selezione un intervallo casuale di tempo
        i=rand()%9+1;
        // avvisa
        printf("Thread %ld: going to sleep for %d sec...\n",who_i_am,i);
        // e dormi
        sleep(i);
        // prova ad acquisire lo spinlock
        if (pthread_spin_trylock(&spinlock)) {
            // in caso contrario avvisa
            printf("Thread %ld: wait for the spinlock...\n",who_i_am);
            // e attendi
            pthread_spin_lock(&spinlock);
        }
        // da qui ho acquisito lo spinlock
        // seleziona un intervallo casuale di tempo
        i=rand()%9+1;
        // avvisa
        printf("Thread %ld: spinlock obtained and now wait for %d sec...\n",who_i_am,i);
        // e dormi
        sleep(i);
        printf("Thread %ld: unlock spinlock...\n",who_i_am);
        // rilascia lo spinlock
        pthread_spin_unlock(&spinlock);
    }
    return NULL;
}
开发者ID:DesiD,项目名称:CsInfoPa,代码行数:41,代码来源:spinlock_cancel.c

示例12: usdf_msg_recv

ssize_t
usdf_msg_recv(struct fid_ep *fep, void *buf, size_t len,
		void *desc, fi_addr_t src_addr, void *context)
{
	struct usdf_ep *ep;
	struct usdf_rx *rx;
	struct usdf_msg_qe *rqe;
	struct usdf_domain *udp;

	ep = ep_ftou(fep);
	rx = ep->ep_rx;
	udp = ep->ep_domain;

	if (TAILQ_EMPTY(&rx->r.msg.rx_free_rqe)) {
		return -FI_EAGAIN;
	}

	pthread_spin_lock(&udp->dom_progress_lock);

	rqe = TAILQ_FIRST(&rx->r.msg.rx_free_rqe);
	TAILQ_REMOVE(&rx->r.msg.rx_free_rqe, rqe, ms_link);
	--rx->r.msg.rx_num_free_rqe;

	rqe->ms_context = context;
	rqe->ms_iov[0].iov_base = buf;
	rqe->ms_iov[0].iov_len = len;
	rqe->ms_last_iov = 0;

	rqe->ms_cur_iov = 0;
	rqe->ms_cur_ptr = buf;
	rqe->ms_iov_resid = len;
	rqe->ms_length = 0;
	rqe->ms_resid = len;

	TAILQ_INSERT_TAIL(&rx->r.msg.rx_posted_rqe, rqe, ms_link);

	pthread_spin_unlock(&udp->dom_progress_lock);

	return 0;
}
开发者ID:patrickmacarthur,项目名称:libfabric,代码行数:40,代码来源:usdf_msg.c

示例13: pthread_setspecific

/**
	@brief This function set value to thread_specific data by the key.
*/
int pthread_setspecific (pthread_key_t key, const void *value)
{
    hurd_ihash_t speci_tb = (hurd_ihash_t)get_current_pt_specific();

    /* key is valid ? */
    if (key > __pthread_key_nums ||
            __destructort_arry[key] == DESTRUCTORT_INVALID)
        return -EINVAL;

    /* has created? */
    if (!speci_tb)
    {
        int ret;

        /* if failt, it must out of memory */
        if (hurd_ihash_create(&speci_tb, HURD_IHASH_NO_LOCP) != 0)
            return -ENOMEM;

        /* add speci_tb to speci_tables */
        pthread_spin_lock(&__pthread_specific_lock);
        ret = find_elem_index_and_add_to_arry(speci_tb, &__pthread_specific_arry, (int *)&__pthread_specific_nums, NULL);
        pthread_spin_unlock(&__pthread_specific_lock);

        /* errno is always no mem */
        if (ret < 0)
        {
            hurd_ihash_destroy(speci_tb);
            return -ENOMEM;
        }

        /* set to pthread */
        set_current_pt_specific((void *)speci_tb);
    }

    /* add to ihash tables */
    if (hurd_ihash_add(speci_tb, (hurd_ihash_key_t)key, (hurd_ihash_value_t)value) != 0)
        return -ENOMEM;

    return 0;
}
开发者ID:LastRitter,项目名称:GridOS,代码行数:43,代码来源:pthread_specific.c

示例14: calqueue_put

void calqueue_put(double timestamp, void *payload) {

	calqueue_node *new_node;

	//printf("calqueue: inserendo %f, cwidth %f, bukettop %f, nbuckets %d, lastprio %f\n", timestamp, cwidth, buckettop, nbuckets, lastprio);

	// Fill the node entry
	new_node = malloc(sizeof(calqueue_node));
	new_node->timestamp = timestamp;
	new_node->payload = payload;
	new_node->next = NULL;

	if(new_node == NULL){
		printf("Out of memory in %s:%d\n", __FILE__, __LINE__);
		abort();
	}

	pthread_spin_lock(&cal_spinlock);
	calqueue_enq(new_node);
	pthread_spin_unlock(&cal_spinlock);

}
开发者ID:HPDCS,项目名称:NPBQ,代码行数:22,代码来源:calqueue.c

示例15: threadFunc

static void *                   /* Loop 'arg' times incrementing 'glob' */
threadFunc(void *arg)
{
    int loops = *((int *) arg);
    int loc, j, s;

    for (j = 0; j < loops; j++) {
        s = pthread_spin_lock(&splock);
        if (s != 0)
            errExitEN(s, "pthread_spin_lock");

        loc = glob;
        loc++;
        glob = loc;

        s = pthread_spin_unlock(&splock);
        if (s != 0)
            errExitEN(s, "pthread_spin_unlock");
    }

    return NULL;
}
开发者ID:duxing2007,项目名称:books-examples,代码行数:22,代码来源:thread_incr_spinlock.c


注:本文中的pthread_spin_unlock函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。