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


C++ sched_gettcb函数代码示例

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


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

示例1: sig_dispatch

int sig_dispatch(pid_t pid, FAR siginfo_t *info)
{
#ifdef HAVE_GROUP_MEMBERS

  FAR struct tcb_s *stcb;
  FAR struct task_group_s *group;

  /* Get the TCB associated with the pid */

  stcb = sched_gettcb(pid);
  if (stcb)
    {
      /* The task/thread associated with this PID is still active.  Get its
       * task group.
       */

      group = stcb->group;
    }
  else
    {
      /* The task/thread associated with this PID has exited.  In the normal
       * usage model, the PID should correspond to the PID of the task that
       * created the task group.  Try looking it up.
       */

      group = group_findbypid(pid);
    }

  /* Did we locate the group? */

  if (group)
    {
      /* Yes.. call group_signal() to send the signal to the correct group
       * member.
       */

      return group_signal(group, info);
    }
  else
    {
      return -ESRCH;
    }

#else

  FAR struct tcb_s *stcb;

  /* Get the TCB associated with the pid */

  stcb = sched_gettcb(pid);
  if (!stcb)
    {
      return -ESRCH;
    }

  return sig_tcbdispatch(stcb, info);

#endif
}
开发者ID:JforGitHub,项目名称:thingsee-sdk,代码行数:59,代码来源:sig_dispatch.c

示例2: sem_timeout

static void sem_timeout(int argc, uint32_t pid)
{
  FAR struct tcb_s *wtcb;
  irqstate_t flags;

  /* Disable interrupts to avoid race conditions */

  flags = irqsave();

  /* Get the TCB associated with this pid.  It is possible that
   * task may no longer be active when this watchdog goes off.
   */

  wtcb = sched_gettcb((pid_t)pid);

  /* It is also possible that an interrupt/context switch beat us to the
   * punch and already changed the task's state.
   */

  if (wtcb && wtcb->task_state == TSTATE_WAIT_SEM)
    {
      /* Cancel the semaphore wait */
 
      sem_waitirq(wtcb, ETIMEDOUT);
    }

  /* Interrupts may now be enabled. */

  irqrestore(flags);
}
开发者ID:1015472,项目名称:PX4NuttX,代码行数:30,代码来源:sem_timedwait.c

示例3: mq_rcvtimeout

static void mq_rcvtimeout(int argc, uint32_t pid)
{
  FAR struct tcb_s *wtcb;
  irqstate_t saved_state;

  /* Disable interrupts.  This is necessary because an interrupt handler may
   * attempt to send a message while we are doing this.
   */

  saved_state = irqsave();

  /* Get the TCB associated with this pid.  It is possible that task may no
   * longer be active when this watchdog goes off.
   */

  wtcb = sched_gettcb((pid_t)pid);

  /* It is also possible that an interrupt/context switch beat us to the
   * punch and already changed the task's state.
   */

  if (wtcb && wtcb->task_state == TSTATE_WAIT_MQNOTEMPTY)
    {
      /* Restart with task with a timeout error */

      mq_waitirq(wtcb, ETIMEDOUT);
    }

  /* Interrupts may now be re-enabled. */

  irqrestore(saved_state);
}
开发者ID:KimMui,项目名称:i2sTest,代码行数:32,代码来源:mq_timedreceive.c

示例4: sched_getscheduler

int sched_getscheduler(pid_t pid)
{
  struct tcb_s *tcb;

  /* Verify that the pid corresponds to a real task */

  if (!pid)
    {
      tcb = (struct tcb_s*)g_readytorun.head;
    }
  else
    {
      tcb = sched_gettcb(pid);
    }

  if (!tcb)
    {
      set_errno(ESRCH);
      return ERROR;
    }
#if CONFIG_RR_INTERVAL > 0
  else if ((tcb->flags & TCB_FLAG_ROUND_ROBIN) != 0)
    {
      return SCHED_RR;
    }
#endif
  else
    {
      return SCHED_FIFO;
    }
}
开发者ID:jrosberg,项目名称:NuttX-L21,代码行数:31,代码来源:sched_getscheduler.c

示例5: cpuload_initialize_once

void cpuload_initialize_once()
{
	system_load.start_time = hrt_absolute_time();
	int i;

	for (i = 0; i < CONFIG_MAX_TASKS; i++) {
		system_load.tasks[i].valid = false;
	}

	int static_tasks_count = 2;	// there are at least 2 threads that should be initialized statically - "idle" and "init"

#ifdef CONFIG_PAGING
	static_tasks_count++;	// include paging thread in initialization
#endif /* CONFIG_PAGING */
#if CONFIG_SCHED_WORKQUEUE
	static_tasks_count++;	// include high priority work0 thread in initialization
#endif /* CONFIG_SCHED_WORKQUEUE */
#if CONFIG_SCHED_LPWORK
	static_tasks_count++;	// include low priority work1 thread in initialization
#endif /* CONFIG_SCHED_WORKQUEUE */

	// perform static initialization of "system" threads
	for (system_load.total_count = 0; system_load.total_count < static_tasks_count; system_load.total_count++) {
		system_load.tasks[system_load.total_count].total_runtime = 0;
		system_load.tasks[system_load.total_count].curr_start_time = 0;
		system_load.tasks[system_load.total_count].tcb = sched_gettcb(
					system_load.total_count);	// it is assumed that these static threads have consecutive PIDs
		system_load.tasks[system_load.total_count].valid = true;
	}
}
开发者ID:2013-8-15,项目名称:Firmware,代码行数:30,代码来源:cpuload.c

示例6: sched_getscheduler

int sched_getscheduler(pid_t pid)
{
  FAR struct tcb_s *tcb;
  int policy;

  /* Verify that the PID corresponds to a real task */

  if (!pid)
    {
      tcb = (struct tcb_s*)g_readytorun.head;
    }
  else
    {
      tcb = sched_gettcb(pid);
    }

  if (!tcb)
    {
      set_errno(ESRCH);
      return ERROR;
    }

  /* Return the scheduling policy from the TCB.  NOTE that the user-
   * interpretable values are 1 based; the TCB values are zero-based.
   */

  policy = (tcb->flags & TCB_FLAG_POLICY_MASK) >> TCB_FLAG_POLICY_SHIFT;
  return policy + 1;
}
开发者ID:nodesign,项目名称:nuttx-kernel,代码行数:29,代码来源:sched_getscheduler.c

示例7: pthread_condtimedout

static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
{
#ifdef HAVE_GROUP_MEMBERS

  FAR struct tcb_s *tcb;
  siginfo_t info;

  /* The logic below if equivalent to sigqueue(), but uses sig_tcbdispatch()
   * instead of sig_dispatch().  This avoids the group signal deliver logic
   * and assures, instead, that the signal is delivered specifically to this
   * thread that is known to be waiting on the signal.
   */

  /* Get the waiting TCB.  sched_gettcb() might return NULL if the task has
   * exited for some reason.
   */

  tcb = sched_gettcb((pid_t)pid);
  if (tcb)
    {
      /* Create the siginfo structure */

      info.si_signo           = signo;
      info.si_code            = SI_QUEUE;
      info.si_errno           = ETIMEDOUT;
      info.si_value.sival_ptr = NULL;
#ifdef CONFIG_SCHED_HAVE_PARENT
      info.si_pid             = (pid_t)pid;
      info.si_status          = OK;
#endif

      /* Process the receipt of the signal.  The scheduler is not locked as
       * is normally the case when this function is called because we are in
       * a watchdog timer interrupt handler.
       */

      (void)sig_tcbdispatch(tcb, &info);
    }

#else /* HAVE_GROUP_MEMBERS */

  /* Things are a little easier if there are not group members.  We can just
   * use sigqueue().
   */

#ifdef CONFIG_CAN_PASS_STRUCTS
  union sigval value;

  /* Send the specified signal to the specified task. */

  value.sival_ptr = NULL;
  (void)sigqueue((int)pid, (int)signo, value);
#else
  (void)sigqueue((int)pid, (int)signo, NULL);
#endif

#endif /* HAVE_GROUP_MEMBERS */
}
开发者ID:rohiniku,项目名称:NuttX-nuttx,代码行数:58,代码来源:pthread_condtimedwait.c

示例8: pg_miss

void pg_miss(void)
{
  FAR struct tcb_s *ftcb = (FAR struct tcb_s*)g_readytorun.head;
  FAR struct tcb_s *wtcb;

  /* Sanity checking
   *
   * ASSERT if the currently executing task is the page fill worker thread.
   * The page fill worker thread is how the page fault is resolved and
   * all logic associated with the page fill worker must be "locked" and
   * always present in memory.
   */

  pglldbg("Blocking TCB: %p PID: %d\n", ftcb, ftcb->pid);
  DEBUGASSERT(g_pgworker != ftcb->pid);

  /* Block the currently executing task
   * - Call up_block_task() to block the task at the head of the ready-
   *   to-run list.  This should cause an interrupt level context switch
   *   to the next highest priority task.
   * - The blocked task will be marked with state TSTATE_WAIT_PAGEFILL
   *   and will be retained in the g_waitingforfill prioritized task list.
   */

  up_block_task(ftcb, TSTATE_WAIT_PAGEFILL);

  /* Boost the page fill worker thread priority.
   * - Check the priority of the task at the head of the g_waitingforfill
   *   list.  If the priority of that task is higher than the current
   *   priority of the page fill worker thread, then boost the priority
   *   of the page fill worker thread to that priority.
   */

  wtcb = sched_gettcb(g_pgworker);
  DEBUGASSERT(wtcb != NULL);

  if (wtcb->sched_priority < ftcb->sched_priority)
    {
      /* Reprioritize the page fill worker thread */

      pgllvdbg("New worker priority. %d->%d\n",
               wtcb->sched_priority, ftcb->sched_priority);
      sched_setpriority(wtcb, ftcb->sched_priority);
    }

  /* Signal the page fill worker thread.
   * - Is there a page fill pending?  If not then signal the worker
   *   thread to start working on the queued page fill requests.
   */

  if (!g_pftcb)
    {
      pglldbg("Signaling worker. PID: %d\n", g_pgworker);
      kill(g_pgworker, SIGWORK);
    }
}
开发者ID:LindaLovelace,项目名称:nuttx-stm32f4disc-bb,代码行数:56,代码来源:pg_miss.c

示例9: prv_fetch_taskaddr

static unsigned long prv_fetch_taskaddr(int pid)
{
	struct tcb_s *tcbptr = sched_gettcb(pid);
	if (tcbptr != NULL) {
		entry_t e = tcbptr->entry;
		if ((tcbptr->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_PTHREAD) {
			return (unsigned long)e.pthread;
		} else {
			return (unsigned long)e.main;
		}
	}
	return 0;
}
开发者ID:tool3210,项目名称:TizenRT,代码行数:13,代码来源:error_report.c

示例10: sched_rr_get_interval

int sched_rr_get_interval(pid_t pid, struct timespec *interval)
{
#if CONFIG_RR_INTERVAL > 0
  FAR struct tcb_s *rrtcb;

  /* If pid is zero, the timeslice for the calling process is written
   * into 'interval.'
   */

  if (!pid)
    {
      rrtcb = (FAR struct tcb_s*)g_readytorun.head;
    }

  /* Return a special error code on invalid PID */

  else if (pid < 0)
    {
      set_errno(EINVAL);
      return ERROR;
    }

  /* Otherwise, lookup the TCB associated with this PID */

  else
    {
      rrtcb = sched_gettcb(pid);
      if (!rrtcb)
        {
          set_errno(ESRCH);
          return ERROR;
        }
    }

  if (!interval)
    {
      set_errno(EFAULT);
      return ERROR;
    }

  /* Convert the timeslice value from ticks to timespec */

  interval->tv_sec  =  CONFIG_RR_INTERVAL / MSEC_PER_SEC;
  interval->tv_nsec = (CONFIG_RR_INTERVAL % MSEC_PER_SEC) * NSEC_PER_MSEC;

  return OK;
#else
  set_errno(ENOSYS);
  return ERROR;
#endif
}
开发者ID:nodesign,项目名称:nuttx-kernel,代码行数:51,代码来源:sched_rrgetinterval.c

示例11: pg_callback

static void pg_callback(FAR struct tcb_s *tcb, int result)
{
  /* Verify that g_pftcb is non-NULL */

  pgllvdbg("g_pftcb: %p\n", g_pftcb);
  if (g_pftcb)
    {
      FAR struct tcb_s *htcb = (FAR struct tcb_s *)g_waitingforfill.head;
      FAR struct tcb_s *wtcb = sched_gettcb(g_pgworker);

      /* Find the higher priority between the task waiting for the fill to
       * complete in g_pftcb and the task waiting at the head of the
       * g_waitingforfill list.  That will be the priority of he highest
       * priority task waiting for a fill.
       */

      int priority = g_pftcb->sched_priority;
      if (htcb && priority < htcb->sched_priority)
        {
          priority = htcb->sched_priority;
        }

      /* If this higher priority is higher than current page fill worker
       * thread, then boost worker thread's priority to that level. Thus,
       * the page fill worker thread will always run at the priority of
       * the highest priority task that is waiting for a fill.
       */

      if (priority > wtcb->sched_priority)
        {
          pgllvdbg("New worker priority. %d->%d\n",
                   wtcb->sched_priority, priority);
          sched_setpriority(wtcb, priority);
        }

      /* Save the page fill result (don't permit the value -EBUSY) */

      if (result == -EBUSY)
        {
          result = -ENOSYS;
        }

      g_fillresult = result;
    }

  /* Signal the page fill worker thread (in any event) */

  pglldbg("Signaling worker. PID: %d\n", g_pgworker);
  kill(g_pgworker, SIGWORK);
}
开发者ID:murix,项目名称:nuttx_ieee80211,代码行数:50,代码来源:pg_worker.c

示例12: taskmgr_task_init

static int taskmgr_task_init(pid_t pid)
{
	struct tcb_s *tcb;
	struct sigaction act;

	tcb = sched_gettcb(pid);
	if (!tcb) {
		tmdbg("[TM] tcb is invalid. pid = %d.\n", pid);
		return ERROR;
	}

	memset(&act, '\0', sizeof(act));
	act.sa_handler = (_sa_handler_t)&taskmgr_pause_handler;

	return sig_sethandler(tcb, SIGTM_PAUSE, &act);
}
开发者ID:tool3210,项目名称:TizenRT,代码行数:16,代码来源:task_manager_drv.c

示例13: sched_getparam

int sched_getparam (pid_t pid, struct sched_param * param)
{
  FAR _TCB *rtcb;
  FAR _TCB *tcb;
  int ret = OK;

  if (!param)
    {
      return ERROR;
    }

  /* Check if the task to restart is the calling task */

  rtcb = (FAR _TCB*)g_readytorun.head;
  if ((pid == 0) || (pid == rtcb->pid))
    {
       /* Return the priority if the calling task. */

       param->sched_priority = (int)rtcb->sched_priority;
    }

  /* Ths pid is not for the calling task, we will have to look it up */

  else
    {
      /* Get the TCB associated with this pid */

      sched_lock();
      tcb = sched_gettcb(pid);
      if (!tcb)
        {
          /* This pid does not correspond to any known task */

          ret = ERROR;
        }
      else
        {
          /* Return the priority of the task */

          param->sched_priority = (int)tcb->sched_priority;
        }
      sched_unlock();
    }

  return ret;
}
开发者ID:andrewms,项目名称:nuttx_ap,代码行数:46,代码来源:sched_getparam.c

示例14: while

static void *setschedprio_test_thread(void *param)
{
	volatile struct tcb_s *set_tcb;

	/*if this thread's priority is changed, we can terminate the loop */
	while (1) {
		set_tcb = sched_gettcb((pid_t)pthread_self());
		if (set_tcb != NULL && set_tcb->sched_priority == 101) {
			break;
		}
		sleep(1);
	}

	check_prio = set_tcb->sched_priority;
	pthread_exit(0);
	return NULL;
}
开发者ID:carhero,项目名称:TizenRT,代码行数:17,代码来源:tc_pthread.c

示例15: task_signalparent

static inline void task_signalparent(FAR struct tcb_s *ctcb, int status)
{
#ifdef HAVE_GROUP_MEMBERS
  DEBUGASSERT(ctcb && ctcb->group);

  /* Keep things stationary throughout the following */

  sched_lock();

  /* Send SIGCHLD to all members of the parent's task group */

  task_sigchild(ctcb->group->tg_pgid, ctcb, status);
  sched_unlock();
#else
  FAR struct tcb_s *ptcb;

  /* Keep things stationary throughout the following */

  sched_lock();

  /* Get the TCB of the receiving, parent task.  We do this early to
   * handle multiple calls to task_signalparent.  ctcb->ppid is set to an
   * invalid value below and the following call will fail if we are
   * called again.
   */

  ptcb = sched_gettcb(ctcb->ppid);
  if (!ptcb)
    {
      /* The parent no longer exists... bail */

      sched_unlock();
      return;
    }

  /* Send SIGCHLD to all members of the parent's task group */

  task_sigchild(ptcb, ctcb, status);

  /* Forget who our parent was */

  ctcb->ppid = INVALID_PROCESS_ID;
  sched_unlock();
#endif
}
开发者ID:acassis,项目名称:ros2_nuttx,代码行数:45,代码来源:task_exithook.c


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