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

C++ enter_critical_section函数代码示例

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

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



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

示例1: group_initialize

int group_initialize(FAR struct task_tcb_s *tcb)
{
  FAR struct task_group_s *group;
#if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV)
  irqstate_t flags;
#endif

  DEBUGASSERT(tcb && tcb->cmn.group);
  group = tcb->cmn.group;

#ifdef HAVE_GROUP_MEMBERS
  /* Allocate space to hold GROUP_INITIAL_MEMBERS members of the group */

  group->tg_members = (FAR pid_t *)kmm_malloc(GROUP_INITIAL_MEMBERS*sizeof(pid_t));
  if (!group->tg_members)
    {
      kmm_free(group);
      return -ENOMEM;
    }

  /* Assign the PID of this new task as a member of the group. */

  group->tg_members[0] = tcb->cmn.pid;

  /* Initialize the non-zero elements of group structure and assign it to
   * the tcb.
   */

  group->tg_mxmembers  = GROUP_INITIAL_MEMBERS; /* Number of members in allocation */

#endif

#if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV)
  /* Add the initialized entry to the list of groups */

  flags = enter_critical_section();
  group->flink = g_grouphead;
  g_grouphead = group;
  leave_critical_section(flags);

#endif

  /* Save the ID of the main task within the group of threads.  This needed
   * for things like SIGCHILD.  It ID is also saved in the TCB of the main
   * task but is also retained in the group which may persist after the main
   * task has exited.
   */

#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
  group->tg_task = tcb->cmn.pid;
#endif

  /* Mark that there is one member in the group, the main task */

  group->tg_nmembers = 1;
  return OK;
}
开发者ID:a1ien,项目名称:nuttx,代码行数:57,代码来源:group_create.c


示例2: enter_critical_section

FAR struct mqueue_msg_s *mq_msgalloc(void)
{
  FAR struct mqueue_msg_s *mqmsg;
  irqstate_t flags;

  /* If we were called from an interrupt handler, then try to get the message
   * from generally available list of messages. If this fails, then try the
   * list of messages reserved for interrupt handlers
   */

  if (up_interrupt_context())
    {
      /* Try the general free list */

      mqmsg = (FAR struct mqueue_msg_s *)sq_remfirst(&g_msgfree);
      if (mqmsg == NULL)
        {
          /* Try the free list reserved for interrupt handlers */

          mqmsg = (FAR struct mqueue_msg_s *)sq_remfirst(&g_msgfreeirq);
        }
    }

  /* We were not called from an interrupt handler. */

  else
    {
      /* Try to get the message from the generally available free list.
       * Disable interrupts -- we might be called from an interrupt handler.
       */

      flags = enter_critical_section();
      mqmsg = (FAR struct mqueue_msg_s *)sq_remfirst(&g_msgfree);
      leave_critical_section(flags);

      /* If we cannot a message from the free list, then we will have to
       * allocate one.
       */

      if (mqmsg == NULL)
        {
          mqmsg = (FAR struct mqueue_msg_s *)
            kmm_malloc((sizeof (struct mqueue_msg_s)));

          /* Check if we allocated the message */

          if (mqmsg != NULL)
            {
              /* Yes... remember that this message was dynamically allocated */

              mqmsg->type = MQ_ALLOC_DYN;
            }
        }
    }

  return mqmsg;
}
开发者ID:a1ien,项目名称:nuttx,代码行数:57,代码来源:mq_sndinternal.c


示例3: l2_inv_all

static void l2_inv_all(void)
{
	/* invalidate all ways */
	enter_critical_section();
	PL310_L2CC->InvalidateByWay = way_mask;
	while (PL310_L2CC->InvalidateByWay & way_mask);
	PL310_L2CC->CacheSync = 0;
	exit_critical_section();
}
开发者ID:791254467,项目名称:MT6589_kernel_source,代码行数:9,代码来源:cache.c


示例4: timer_start

/****************************************************************************
 * Name: timer_start
 *
 * Description:
 *   Is used to Start a timer. The reload value is copied to the counter.
 *   And the running bit it set. There is no problem in Starting a running
 *   timer. But it will restart the timeout.
 *
 * Input Parameters:
 *   id - Returned from timer_allocate;
 *
 * Returned Value:
 *   None.
 *
 ****************************************************************************/
void timer_start(bl_timer_id id)
{
	DEBUGASSERT(id >= 0 && id < arraySize(timers) && (timers[id].ctl & inuse));
	irqstate_t s = enter_critical_section();
	timers[id].count = timers[id].reload;
	timers[id].ctl |= running;
	leave_critical_section(s);

}
开发者ID:andre-nguyen,项目名称:Firmware,代码行数:24,代码来源:timer.c


示例5: mm_takesemaphore

void mm_takesemaphore(FAR struct mm_heap_s *heap)
{
#ifdef CONFIG_SMP
  irqstate_t flags = enter_critical_section();
#endif
  pid_t my_pid = getpid();

  /* Do I already have the semaphore? */

  if (heap->mm_holder == my_pid)
    {
      /* Yes, just increment the number of references that I have */

      heap->mm_counts_held++;
    }
  else
    {
      int ret;

      /* Take the semaphore (perhaps waiting) */

      mseminfo("PID=%d taking\n", my_pid);
      do
        {
          ret = _SEM_WAIT(&heap->mm_semaphore);

          /* The only case that an error should occur here is if the wait
           * was awakened by a signal.
           */

          if (ret < 0)
            {
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
              DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
#else
              int errcode = get_errno();
              DEBUGASSERT(errcode == EINTR || errcode == ECANCELED);
              ret = -errcode;
#endif
            }
        }
      while (ret == -EINTR);

      /* We have it (or some awful, unexpected error occurred).  Claim
       * the semaphore and return.
       */

      heap->mm_holder      = my_pid;
      heap->mm_counts_held = 1;
    }

#ifdef CONFIG_SMP
  leave_critical_section(flags);
#endif
  mseminfo("Holder=%d count=%d\n", heap->mm_holder, heap->mm_counts_held);
}
开发者ID:dagar,项目名称:NuttX,代码行数:56,代码来源:mm_sem.c


示例6: enter_critical_section

FAR sigq_t *sig_allocatependingsigaction(void)
{
  FAR sigq_t    *sigq;
  irqstate_t flags;

  /* Check if we were called from an interrupt handler. */

  if (up_interrupt_context())
    {
      /* Try to get the pending signal action structure from the free list */

      sigq = (FAR sigq_t *)sq_remfirst(&g_sigpendingaction);

      /* If so, then try the special list of structures reserved for
       * interrupt handlers
       */

      if (!sigq)
        {
          sigq = (FAR sigq_t *)sq_remfirst(&g_sigpendingirqaction);
        }
    }

  /* If we were not called from an interrupt handler, then we are
   * free to allocate pending signal action structures if necessary. */

  else
    {
      /* Try to get the pending signal action structure from the free list */

      flags = enter_critical_section();
      sigq = (FAR sigq_t *)sq_remfirst(&g_sigpendingaction);
      leave_critical_section(flags);

      /* Check if we got one. */

      if (!sigq)
        {
          /* No...Try the resource pool */

          if (!sigq)
            {
              sigq = (FAR sigq_t *)kmm_malloc((sizeof (sigq_t)));
            }

          /* Check if we got an allocated message */

          if (sigq)
            {
              sigq->type = SIG_ALLOC_DYN;
            }
        }
    }

  return sigq;
}
开发者ID:a1ien,项目名称:nuttx,代码行数:56,代码来源:sig_allocatependingsigaction.c


示例7: cbVMStart

/* Callback for JVMTI_EVENT_VM_START */
static void JNICALL
cbVMStart(jvmtiEnv *jvmti, JNIEnv *env)
{
    enter_critical_section(jvmti);
    {
        /* Indicate VM has started */
        gdata->vm_is_started = JNI_TRUE;
    }
    exit_critical_section(jvmti);
}
开发者ID:netroby,项目名称:jdk9-dev,代码行数:11,代码来源:minst.c


示例8: register_int_handler

void register_int_handler(unsigned int vector, int_handler func, void *arg)
{
    if (vector >= NR_IRQS)
        return;

    enter_critical_section();
    handler[vector].func = func;
    handler[vector].arg = arg;
    exit_critical_section();
}
开发者ID:boiert,项目名称:lk-msm7200a-htc-wince,代码行数:10,代码来源:interrupts.c


示例9: target_shutdown

void target_shutdown(void)
{
	enter_critical_section();
	
	if(fbcon_display())
		htcleo_display_shutdown();
	platform_exit();
	msm_proc_comm(PCOM_POWER_DOWN, 0, 0);
	for (;;) ;
}
开发者ID:sndnvaps,项目名称:HTC-leo-cLK,代码行数:10,代码来源:init.c


示例10: clock_synchronize

void clock_synchronize(void)
{
  irqstate_t flags;

  /* Re-initialize the time value to match the RTC */

  flags = enter_critical_section();
  clock_inittime();
  leave_critical_section(flags);
}
开发者ID:a1ien,项目名称:nuttx,代码行数:10,代码来源:clock_initialize.c


示例11: nvram_display_list

void nvram_display_list() {
	NvramVar* var = (NvramVar*) gNvramList->next;
	enter_critical_section();
	while(var != (void*) gNvramList) {
		printf("0x%08x: %s = %s\n", var, var->name, var->string);
		var = var->next;
	}
	printf("\n");
	exit_critical_section();
}
开发者ID:sbingner,项目名称:cyanide,代码行数:10,代码来源:nvram.c


示例12: timer_delete

void timer_delete(timer_list_t *timer)
{
    enter_critical_section();
    
    if (list_in_list(&timer->node)) {
        list_delete(&timer->node);
    }

    exit_critical_section();
}
开发者ID:Shikhin,项目名称:tart,代码行数:10,代码来源:timer.c


示例13: board_button_irq

xcpt_t board_button_irq(int id, xcpt_t irqhandler)
{
  xcpt_t oldhandler = NULL;

  if (id >=0 && id < NUM_BUTTONS)
    {
      irqstate_t flags;

      /* Disable interrupts until we are done.  This guarantees that the
       * following operations are atomic.
       */

      flags = enter_critical_section();

      /* Get/set the old button handler
       *
       * REVISIT:  Keeping copies of the hander in RAM seems wasteful
       * since the OS already has this information internally.
       */

#if 0 /* REVISIT */
      oldhandler = g_button_handlers[id];
      g_button_handlers[id] = irqhandler;
#else
      oldhandler = NULL;
#endif

      /* Are we attaching or detaching? */

      if (irqhandler != NULL)
        {
          /* Configure the interrupt */

          efm32_gpioirq(g_button_configs[id]);

          /* Attach and enable the interrupt */

          (void)irq_attach(g_button_irqs[id], irqhandler);
          efm32_gpioirqenable(g_button_irqs[id]);
        }
      else
        {
          /* Disable and detach the interrupt */

          efm32_gpioirqdisable(g_button_irqs[id]);
          (void)irq_detach(g_button_irqs[id]);
        }

      leave_critical_section(flags);
    }

  /* Return the old button handler (so that it can be restored) */

  return oldhandler;
}
开发者ID:a1ien,项目名称:nuttx,代码行数:55,代码来源:efm32_buttons.c


示例14: platform_set_periodic_timer

status_t platform_set_periodic_timer(platform_timer_callback callback,
	void *arg, time_t interval)
{

	enter_critical_section();

	qtimer_set_physical_timer(interval, callback, arg);

	exit_critical_section();
	return 0;
}
开发者ID:GoldRenard,项目名称:android_bootable_bootloader_lk-shellr,代码行数:11,代码来源:qtimer.c


示例15: next_thread_id

static jlong next_thread_id() {
  // mark the thread - with lock
  // TODO replace total ordering lock with private lock - perf. issue
  jlong result = -1;
  enter_critical_section(jvmti_env, threadID_lock);
  {
    result = avail_thread_id++;
  }
  exit_critical_section(jvmti_env, threadID_lock);
  return result;
}
开发者ID:mur47x111,项目名称:svm-fasttagging,代码行数:11,代码来源:tlocalbuffer.c


示例16: target_reboot

void target_reboot(unsigned reboot_reason)
{
	enter_critical_section();
	
	if(fbcon_display())
		htcleo_display_shutdown();
	platform_exit();
	writel(reboot_reason, LK_BOOTREASON_ADDR);
	writel(reboot_reason^MARK_LK_TAG, LK_BOOTREASON_ADDR + 4);
	reboot(reboot_reason);
}
开发者ID:sndnvaps,项目名称:HTC-leo-cLK,代码行数:11,代码来源:init.c


示例17: bootlinux_direct

void bootlinux_direct(void *kernel, unsigned machtype, unsigned *tags)
{
	void (*entry)(unsigned,unsigned,unsigned*) = kernel;

	enter_critical_section();
	/* do any platform specific cleanup before kernel entry */
	platform_uninit();
	arch_disable_cache(UCACHE);
	arch_disable_mmu();
	entry(0, machtype, tags);
}
开发者ID:manhthiep,项目名称:moboot,代码行数:11,代码来源:bootlinux.c


示例18: modifyreg8

void modifyreg8(unsigned int addr, uint8_t clearbits, uint8_t setbits)
{
  irqstate_t flags;
  uint8_t    regval;

  flags   = enter_critical_section();
  regval  = getreg8(addr);
  regval &= ~clearbits;
  regval |= setbits;
  putreg8(regval, addr);
  leave_critical_section(flags);
}
开发者ID:AlexShiLucky,项目名称:NuttX,代码行数:12,代码来源:up_modifyreg8.c


示例19: register_int_handler

void register_int_handler(unsigned int vector, int_handler handler, void *arg)
{
    if (vector >= INT_VECTORS)
        panic("register_int_handler: vector out of range %d\n", vector);

    enter_critical_section();

    int_handler_table[vector].handler = handler;
    int_handler_table[vector].arg = arg;

    exit_critical_section();
}
开发者ID:zeusk,项目名称:lk,代码行数:12,代码来源:interrupts.c


示例20: platform_deinit_interrupts

void platform_deinit_interrupts(void) {
    enter_critical_section();
    writel(0, VIC_INT_MASTEREN);
    writel(0xffffffff, VIC_INT_CLEAR0);
    writel(0xffffffff, VIC_INT_CLEAR1);
    writel(0, VIC_INT_SELECT0);
    writel(0, VIC_INT_SELECT1);
    writel(0xffffffff, VIC_INT_TYPE0);
    writel(0xffffffff, VIC_INT_TYPE1);
    writel(0, VIC_CONFIG);
    exit_critical_section();
}
开发者ID:boiert,项目名称:lk-msm7200a-htc-wince,代码行数:12,代码来源:interrupts.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ enter_function函数代码示例发布时间:2022-05-30
下一篇:
C++ enter_blocking_section函数代码示例发布时间: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