• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ release_lock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: nrnbbs_take_string

boolean nrnbbs_take_string(const char* key, char* sval) {
	history("take", key);
	get_lock();
	boolean b = false;
	FILE* f = fopen(fname(NRNBBS), "r");
	if (f != (FILE*)0) {
		char name[256], val[256];
		FILE* f2 = fopen(fname(TMPFILE), "w");
		while (fgets(name, 256, f)) {
			name[strlen(name) -1] = '\0';
			if (name[0] == '\0') {
				continue;
			}
			fgets(val, 256, f);
			val[strlen(val) - 1] = '\0';
			if (!b && strcmp(name, key) == 0) {
				history("  found", val);
				b = true;
				strcpy(sval, val);
				continue;
			}
			fprintf(f2, "%s\n%s\n", name, val);
		}
		fclose(f2);
		fclose(f);
		if (b) {
			rename(fname(TMPFILE), fname(NRNBBS));
		}
	}else{
		b = false;
	}
	release_lock();
	return b;
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:34,代码来源:nrnbbs.cpp


示例2: hao_initialize

/*---------------------------------------------------------------------------*/
static int hao_initialize(void)
{
  int i = 0;
  int rc;

  initialize_lock(&ao_lock);

  /* serialize */
  obtain_lock(&ao_lock);

  /* initialize variables */
  for(i = 0; i < HAO_MAXRULE; i++)
  {
    ao_cmd[i] = NULL;
    ao_tgt[i] = NULL;
  }

  /* initialize message buffer */
  memset(ao_msgbuf, 0, sizeof(ao_msgbuf));

  /* Start message monitoring thread */
  rc = create_thread (&haotid, JOINABLE, hao_thread, NULL, "hao_thread");
  if(rc)
  {
    i = FALSE;
    WRMSG(HHC00102, "E", strerror(rc));
  }
  else
    i = TRUE;

  release_lock(&ao_lock);

  return(i);
}
开发者ID:Orfheo,项目名称:hyperion,代码行数:35,代码来源:hao.c


示例3: sys_sem_create

  /***************************************************************************
  Function: sys_sem_create
  
  Description: 
  
  Parameters: 
  
  Returns: boolean indicating success or failure

  ***************************************************************************/
  mrapi_boolean_t sys_sem_create(int key,int num_locks,int* id) {
    int i;

    /* critical section:
       We don't want anyone else creating/deleting while we are creating */
    acquire_lock(&mrapi_db->global_lock);
    
    /* first make sure it doesn't already exist */        
    for (i = 0; i < MRAPI_MAX_SEMS; i++) {
      if ((mrapi_db->sys_sems[i].key == key) && 
          (mrapi_db->sys_sems[i].valid)) {
        break;
      }
    }
    if (i == MRAPI_MAX_SEMS) {
      /* we didn't find it so create it */
      for (i = 0; i < MRAPI_MAX_SEMS; i++) {
        if (!mrapi_db->sys_sems[i].valid) {
          memset(&mrapi_db->sys_sems[i],0,sizeof(mrapi_sys_sem_t));
          mrapi_db->sys_sems[i].valid = MRAPI_TRUE;
          mrapi_db->sys_sems[i].key = key;
          mrapi_db->sys_sems[i].num_locks = num_locks;
        }
      }
    }
    release_lock(&mrapi_db->global_lock);
    if (i == MRAPI_MAX_SEMS) {
      *id = -1;
      return MRAPI_FALSE;
    } else {
      *id = i;
      return MRAPI_TRUE;
    }
  }
开发者ID:jgphpc,项目名称:OpenMP_MCA_Project,代码行数:44,代码来源:mrapi_powerpc.c


示例4: hao_initialize

/*---------------------------------------------------------------------------*/
DLL_EXPORT int hao_initialize(void)
{
  int i = 0;

  initialize_lock(&ao_lock);

  /* serialize */
  obtain_lock(&ao_lock);

  /* initialize variables */
  for(i = 0; i < HAO_MAXRULE; i++)
  {
    ao_cmd[i] = NULL;
    ao_tgt[i] = NULL;
  }

  /* initialize message buffer */
  memset(ao_msgbuf, 0, sizeof(ao_msgbuf));

  /* Start message monitoring thread */
  if ( create_thread (&sysblk.haotid, JOINABLE,
    hao_thread, NULL, "hao_thread") )
  {
    i = FALSE;
  }
  else
    i = TRUE;

  release_lock(&ao_lock);

  return(i);
}
开发者ID:2kranki,项目名称:spinhawk,代码行数:33,代码来源:hao.c


示例5: add_socket_devices_to_fd_set

/*-------------------------------------------------------------------*/
int add_socket_devices_to_fd_set (int maxfd, fd_set* readset)
{
    DEVBLK* dev;
    bind_struct* bs;
    LIST_ENTRY*  pListEntry;

    obtain_lock(&bind_lock);

    pListEntry = bind_head.Flink;

    while (pListEntry != &bind_head)
    {
        bs = CONTAINING_RECORD(pListEntry,bind_struct,bind_link);

        if (bs->sd != -1)           /* if listening for connections, */
        {
            dev = bs->dev;

            FD_SET(bs->sd, readset);    /* then add file to set */

            if (bs->sd > maxfd)
                maxfd = bs->sd;
        }

        pListEntry = pListEntry->Flink;
    }

    release_lock(&bind_lock);

    return maxfd;
}
开发者ID:CrashSerious,项目名称:Pi-hercules,代码行数:32,代码来源:sockdev.c


示例6: quit_handler

static void quit_handler(int signo, siginfo_t *info, void *context)
{
	cl_log(LOG_INFO, "quit_handler called. now releasing lock\n");
	release_lock();
	cl_log(LOG_INFO, "Shutdown sfex_daemon with EXIT_SUCCESS\n");
	exit(EXIT_SUCCESS);
}
开发者ID:knakahira,项目名称:resource-agents,代码行数:7,代码来源:sfex_daemon.c


示例7: cleanup

static void
cleanup(debug_context_t * dc)
{
  dc->stop_reason = CTX_STOP_NONE;

  release_lock();
}
开发者ID:Alex-Aralis,项目名称:davey-rails-app,代码行数:7,代码来源:byebug.c


示例8: main

main() {
    char *mem_ptr, *ctime();
    long now;
    int n;

    seg_id = shmget(TIME_MEM_KEY, SEG_SIZE, IPC_CREAT|0777);
    if( seg_id == -1 )
        oops("shmget", 1);
    mem_ptr = shmat(seg_id, NULL, 0);
    if (mem_ptr == (void *) -1)
        oops("shmat", 2);

    semset_id = semget(TIME_SEM_KEY, 2, (0666|IPC_CREAT|IPC_EXCL));

    if (semset_id == -1)
        oops("segget", 3);

    set_sem_value(semset_id, 0, 0);
    set_sem_value(semset_id, 1, 0);

    signal(SIGINT, cleanup);

    for (n = 0; n < 60; n++) {
        time(&now);
        printf("\t shm_ts2 waiting for lock\n");
        wait_and_lock(semset_id);
        printf("\t shm_ts2 updateing memory\n");
        strcpy(mem_ptr, ctime(&now));
        sleep(5);
        release_lock(semset_id);
        printf("\t shm_ts released lock\n");
        sleep(1);
    }
    cleanup(0);
}
开发者ID:xegg,项目名称:JustSomeLearningNoteAndScript,代码行数:35,代码来源:shm_ts2.c


示例9: TAS_backoff__main

void TAS_backoff__main(){
	while(1){
		acquire_lock();
		c++; assert(c == 1); c--;
		release_lock();
	}
}
开发者ID:olivo,项目名称:BP,代码行数:7,代码来源:main.c


示例10: log_event

void log_event(char *message)
{
    FILE *file;
    struct tm *current_info;
    time_t current;
    char times[50];
    int filedes;
    
    time(&current);
    current_info = localtime(&current);
    current = mktime(current_info);
    strftime(times,25,"%b %d %Y %H:%M",localtime(&current));

    filedes = open("event.log", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
    if (filedes < 0) {
        fprintf(stderr, "Cannot Get Event Log File Descriptor\n");
	exit(EXIT_FAILURE);
    }
    
    if(get_lock(filedes) < 0) {
        fprintf(stderr, "Cannot Obtain Event Log File Lock\n");
	exit(EXIT_FAILURE);
    }
    
    file = fdopen(filedes, "a");

    fprintf(file, "%s %s\n", times,message);
    release_lock(filedes);
    fclose(file);
    close(filedes);
}
开发者ID:padraigoleary,项目名称:PEOS,代码行数:31,代码来源:process.c


示例11: hao_clear

/*---------------------------------------------------------------------------*/
static void hao_clear(void)
{
  int i;

  /* serialize */
  obtain_lock(&ao_lock);

  /* clear all defined rules */
  for(i = 0; i < HAO_MAXRULE; i++)
  {
    if(ao_tgt[i])
    {
      free(ao_tgt[i]);
      ao_tgt[i] = NULL;
      regfree(&ao_preg[i]);
    }
    if(ao_cmd[i])
    {
      free(ao_cmd[i]);
      ao_cmd[i] = NULL;
    }
  }

  release_lock(&ao_lock);
  logmsg(HHCAO022I);
}
开发者ID:2kranki,项目名称:spinhawk,代码行数:27,代码来源:hao.c


示例12: RLock_release

static PyObject *
RLock_release(RLock *self, PyObject *args)
{
    long tid = PyThread_get_thread_ident();

    if (self->count == 0 || self->owner != tid) {
        PyErr_SetString(PyExc_RuntimeError,
                        "cannot release un-acquired lock");
        return NULL;
    }

    if (self->count > 1) {
        --self->count;
        Py_RETURN_NONE;
    }

    assert(self->count == 1);
    if (release_lock(&self->sem) != 0)
        return NULL;

    self->count = 0;
    self->owner = 0;

    Py_RETURN_NONE;
}
开发者ID:mureinik,项目名称:cthreading,代码行数:25,代码来源:_cthreading.c


示例13: nrnbbs_post_string

void nrnbbs_post_string(const char* key, const char* sval) {
	history("post", key, sval);
	get_lock();
	FILE* f = fopen(fname(NRNBBS), "a");
	fprintf(f, "%s\n%s\n", key, sval);
	FILE* f2 = fopen(fname(NOTIFY), "r");
	char name[256];
	int i, n, id[10];
	n = 0;
	if (f2) {
		while( fgets(name, 256, f2) && n < 10) {
			name[strlen(name) - 1] = '\0';
			fscanf(f2, "%d\n", &i);
			if (strcmp(name, key) == 0) {
				id[n++] = i;
				fprintf(f, "nrnbbs_notifying %s\n\n", key);
			}
		}
		fclose(f2);
	}
	fclose(f);
	release_lock();
	for (i=0; i < n; ++i) {
		history("  notify", id[i]);
		kill(id[i], NOTIFY_SIGNAL);
	}
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:27,代码来源:nrnbbs.cpp


示例14: release_lock

/** Close the project (reclaiming all memory) */
bool
Project::close ( void )
{
    if ( ! open() )
        return true;

    if ( ! save() )
        return false;
    
    Loggable::close();

//    write_info();

    _is_open = false;

    *Project::_name = '\0';
    *Project::_created_on = '\0';

    release_lock( &_lockfd, ".lock" );

    delete engine;
    engine = NULL;

    return true;
}
开发者ID:jeremyz,项目名称:non,代码行数:26,代码来源:Project.C


示例15: lockfile_unlock

static int lockfile_unlock(lockfile_t *lf)
{
    if (!lf || lf->fd == -1) {
        return ERROR;
    }

    if (release_lock(lf->fd, 0, SEEK_SET, 0) == ERROR) {
        /* Unlock entire file */
        logger.error("Failed to unlock %s: %s",
                     lf->file, strerror(errno));
        return ERROR;
    }

    close(lf->fd);

    logger.info("Released PID file lock");

    lf->fd = -1;

    if (remove(lf->file) == ERROR) {
        logger.warn("Failed to remove %s: %s",
                    lf->file, strerror(errno));
        return ERROR;
    }

    return OK;
}
开发者ID:jmarkowski,项目名称:keylogger,代码行数:27,代码来源:lockfile.c


示例16: thr1

void thr1(){
	while(1){
		acquire_lock();
		c++; assert(c == 1); c--;
		release_lock();
	}
}
开发者ID:olivo,项目名称:BP,代码行数:7,代码来源:main.c


示例17: timer_thread

void timer_thread(void*){
	sch_set_priority(2);
	while(true){
		sch_setblock(&events_blockcheck, NULL);
		sch_setblock(&next_event_blockcheck, NULL);
		take_lock_exclusive(timer_lock);
		timer_event *last_event = nullptr;
		if(next_event){
			if(!next_event->cancel){
				btos_api::bt_msg_header msg;
				msg.from = 0;
				msg.to = next_event->pid;
				msg.source = extension_id;
				msg.type = 0;
				msg.critical = 0;
				msg.flags = 0;
				msg.length = sizeof(bt_handle_t);
				msg.content = malloc(sizeof(bt_handle_t));
				timer_info *timer = (*timers)[next_event->timer_id];
				*(bt_handle_t*)msg.content = timer->handle_id;
				timer->active = false;
				msg_send(msg);
			}
			events->erase(events->find(next_event));
			last_event = next_event;
		}
		update_next_event();
		release_lock(timer_lock);
		if(last_event) delete last_event;
	}
}
开发者ID:mallardtheduck,项目名称:osdev,代码行数:31,代码来源:timer.cpp


示例18: acquire_lock

memory_entry *memory_entry::allocate(size_t size, void *base, const char *file, int line)
{
	acquire_lock();

	// if we're out of free entries, allocate a new chunk
	if (s_freehead == NULL)
	{
		// create a new chunk, and fail if we can't
		memory_entry *entry = reinterpret_cast<memory_entry *>(osd_malloc_array(memory_block_alloc_chunk * sizeof(memory_entry)));
		if (entry == NULL)
		{
			release_lock();
			return NULL;
		}

		// add all the entries to the list
		for (int entrynum = 0; entrynum < memory_block_alloc_chunk; entrynum++)
		{
			entry->m_next = s_freehead;
			s_freehead = entry++;
		}
	}

	// grab a free entry
	memory_entry *entry = s_freehead;
	s_freehead = entry->m_next;

	// populate it
	entry->m_size = size;
	entry->m_base = base;
	entry->m_file = s_tracking ? file : NULL;
	entry->m_line = s_tracking ? line : 0;
	entry->m_id = s_curid++;
	if (LOG_ALLOCS)
		fprintf(stderr, "#%06d, alloc %d bytes (%s:%d)\n", (UINT32)entry->m_id, static_cast<UINT32>(entry->m_size), entry->m_file, (int)entry->m_line);

	// add it to the alloc list
	int hashval = reinterpret_cast<FPTR>(base) % k_hash_prime;
	entry->m_next = s_hash[hashval];
	if (entry->m_next != NULL)
		entry->m_next->m_prev = entry;
	entry->m_prev = NULL;
	s_hash[hashval] = entry;

	release_lock();
	return entry;
}
开发者ID:LibXenonProject,项目名称:mame-lx,代码行数:47,代码来源:emualloc.c


示例19: hci_smd_recv_event

static void hci_smd_recv_event(void)
{
	int len = 0;
	int rc = 0;
	struct sk_buff *skb = NULL;
	struct hci_smd_data *hsmd = &hs;
	wake_lock(&hs.wake_lock_rx);

	len = smd_read_avail(hsmd->event_channel);
	if (len > HCI_MAX_FRAME_SIZE) {
		BT_ERR("Frame larger than the allowed size, flushing frame");
		rc = smd_read(hsmd->event_channel, NULL, len);
		goto out_event;
	}

	while (len > 0) {
		skb = bt_skb_alloc(len, GFP_ATOMIC);
		if (!skb) {
			BT_ERR("Error in allocating socket buffer");
			smd_read(hsmd->event_channel, NULL, len);
			goto out_event;
		}

		rc = smd_read(hsmd->event_channel, skb_put(skb, len), len);
		if (rc < len) {
			BT_ERR("Error in reading from the event channel");
			goto out_event;
		}

		skb->dev = (void *)hsmd->hdev;
		bt_cb(skb)->pkt_type = HCI_EVENT_PKT;

		skb_orphan(skb);

		rc = hci_recv_frame(skb);
		if (rc < 0) {
			BT_ERR("Error in passing the packet to HCI Layer");
			/*
			 * skb is getting freed in hci_recv_frame, making it
			 *  to null to avoid multiple access
			 */
			skb = NULL;
			goto out_event;
		}

		len = smd_read_avail(hsmd->event_channel);
		/*
		 * Start the timer to monitor whether the Rx queue is
		 * empty for releasing the Rx wake lock
		 */
		BT_DBG("Rx Timer is starting");
		mod_timer(&hsmd->rx_q_timer,
				jiffies + msecs_to_jiffies(RX_Q_MONITOR));
	}
out_event:
	release_lock();
	if (rc)
		kfree_skb(skb);
}
开发者ID:GTurn,项目名称:Matrix_Force,代码行数:59,代码来源:hci_smd.c


示例20: next_event_blockcheck

bool next_event_blockcheck(void*){
	if(try_take_lock_exclusive(timer_lock)){
		bool ret = next_event ? get_msecs() >= next_event->time : false;
		release_lock(timer_lock);
		return ret;
	}
	return false;
}
开发者ID:mallardtheduck,项目名称:osdev,代码行数:8,代码来源:timer.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ release_mem_region函数代码示例发布时间:2022-05-30
下一篇:
C++ release_l3_process函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap