Пример #1
0
void killall()
{
//	printf("Sending SIGUSR1 to all processes now\n");

	/* iterate through all tasks and send kill signal */
	sched_foreach(kill_task, NULL);
}
Пример #2
0
void _exit(int status)
{
  FAR struct tcb_s* tcb;

  /* Disable interrupts.  Interrupts will remain disabled until
   * the new task is resumed below.
   */

  (void)irqsave();

  slldbg("TCB=%p exitting\n", tcb);

#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
  lldbg("Other tasks:\n");
  sched_foreach(_up_dumponexit, NULL);
#endif

  /* Destroy the task at the head of the ready to run list. */

  (void)task_deletecurrent();

  /* Now, perform the context switch to the new ready-to-run task at the
   * head of the list.
   */

  tcb = (FAR struct tcb_s*)g_readytorun.head;
  slldbg("New Active Task TCB=%p\n", tcb);

  /* Then switch contexts */

  RESTORE_USERCONTEXT(tcb);
}
Пример #3
0
void _exit(int status)
{
  _TCB* tcb;

  /* Disable interrupts.  They will be restored when the next
   * task is started.
   */

  (void)irqsave();

  slldbg("TCB=%p exitting\n", g_readytorun.head);

#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
  slldbg("Other tasks:\n");
  sched_foreach(_up_dumponexit, NULL);
#endif

  /* Destroy the task at the head of the ready to run list. */

  (void)task_deletecurrent();

  /* Now, perform the context switch to the new ready-to-run task at the
   * head of the list.
   */

  tcb = (_TCB*)g_readytorun.head;

  /* Then switch contexts */

  up_fullcontextrestore(tcb->xcp.regs);
}
Пример #4
0
int main(int argc, char *argv[])
{
  puts(
	"Content-type: text/html\r\n"
	"Status: 200/html\r\n"
	"\r\n"
    "<html>\r\n"
      "<head>\r\n"
        "<title>NuttX Tasks</title>\r\n"
        "<link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\">\r\n"
      "</head>\r\n"
      "<body bgcolor=\"#fffeec\" text=\"black\">\r\n"
        "<div class=\"menu\">\r\n"
        "<div class=\"menubox\"><a href=\"/index.html\">Front page</a></div>\r\n"
        "<div class=\"menubox\"><a href=\"hello\">Say Hello</a></div>\r\n"
        "<div class=\"menubox\"><a href=\"tasks\">Tasks</a></div>\r\n"
        "<div class=\"menubox\"><a href=\"netstat\">Network status</a></div>\r\n"
        "<br>\r\n"
        "</div>\r\n"
        "<div class=\"contentblock\">\r\n"
        "<pre>\r\n"
        "PID   PRI SCHD TYPE   NP STATE    NAME\r\n");

  sched_foreach(show_task, NULL);

  puts(
        "</pre>\r\n"
      "</body>\r\n"
   "</html>\r\n");
  return 0;
}
Пример #5
0
void _exit(int status)
{
    struct tcb_s *tcb;

    /* Disable interrupts.  They will be restored when the next task is
     * started.
     */

    (void)up_irq_save();

    sinfo("TCB=%p exiting\n", this_task());

#ifdef CONFIG_DUMP_ON_EXIT
    sinfo("Other tasks:\n");
    sched_foreach(_xtensa_dumponexit, NULL);
#endif

#if XCHAL_CP_NUM > 0
    /* Disable co-processor support for the task that is exit-ing. */

    tcb = this_task();
    xtensa_coproc_disable(&tcb->xcp.cpstate, XTENSA_CP_ALLSET);
#endif

    /* Destroy the task at the head of the ready to run list. */

    (void)task_exit();

    /* Now, perform the context switch to the new ready-to-run task at the
     * head of the list.
     */

    tcb = this_task();

#if XCHAL_CP_NUM > 0
    /* Set up the co-processor state for the newly started thread. */

    xtensa_coproc_restorestate(&tcb->xcp.cpstate);
#endif

#ifdef CONFIG_ARCH_ADDRENV
    /* Make sure that the address environment for the previously running
     * task is closed down gracefully (data caches dump, MMU flushed) and
     * set up the address environment for the new thread at the head of
     * the ready-to-run list.
     */

    (void)group_addrenv(tcb);
#endif

    /* Then switch contexts */

    xtensa_context_restore(tcb->xcp.regs);

    /* xtensa_full_context_restore() should not return but could if the software
     * interrupts are disabled.
     */

    PANIC();
}
static int stackmonitor_daemon(int argc, char **argv)
{
  syslog(LOG_INFO, STKMON_PREFIX "Running: %d\n", g_stackmonitor.pid);

  /* Loop until we detect that there is a request to stop. */

  while (!g_stackmonitor.stop)
    {
      sleep(CONFIG_SYSTEM_STACKMONITOR_INTERVAL);
#if CONFIG_TASK_NAME_SIZE > 0
      syslog(LOG_INFO, "%-5s %-6s %-6s %s\n", "PID", "SIZE", "USED", "THREAD NAME");
#else
      syslog(LOG_INFO, "%-5s %-6s %-6s\n", "PID", "SIZE", "USED");
#endif
      sched_foreach(stkmon_task, NULL);
    }

  /* Stopped */

  g_stackmonitor.stop    = false;
  g_stackmonitor.started = false;
  syslog(LOG_INFO, STKMON_PREFIX "Stopped: %d\n", g_stackmonitor.pid);

  return 0;
}
Пример #7
0
void stkmon_disp(void)
{
#if CONFIG_TASK_NAME_SIZE > 0
  syslog(LOG_INFO, "%-5s %-6s %-6s %s\n", "PID", "SIZE", "USED", "THREAD NAME");
#else
  syslog(LOG_INFO, "%-5s %-6s %-6s\n", "PID", "SIZE", "USED");
#endif
  sched_foreach(_stkmon_disp, NULL);
}
Пример #8
0
int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
#ifdef HAVE_CPULOAD
    nsh_output(vtbl, "PID   PRI SCHD TYPE   NP STATE    CPU    NAME\n");
#else
    nsh_output(vtbl, "PID   PRI SCHD TYPE   NP STATE    NAME\n");
#endif
    sched_foreach(ps_task, vtbl);
    return OK;
}
Пример #9
0
void _exit(int status)
{
  struct tcb_s *tcb;

  /* Disable interrupts.  They will be restored when the next
   * task is started.
   */

  (void)irqsave();

  slldbg("TCB=%p exiting\n", this_task());

#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
  slldbg("Other tasks:\n");
  sched_foreach(_up_dumponexit, NULL);
#endif

  /* Destroy the task at the head of the ready to run list. */

  (void)task_exit();

  /* Now, perform the context switch to the new ready-to-run task at the
   * head of the list.
   */

  tcb = this_task();

#ifdef CONFIG_ARCH_ADDRENV
  /* Make sure that the address environment for the previously running
   * task is closed down gracefully (data caches dump, MMU flushed) and
   * set up the address environment for the new thread at the head of
   * the ready-to-run list.
   */

  (void)group_addrenv(tcb);
#endif

  /* Then switch contexts */

  up_fullcontextrestore(tcb->xcp.regs);

  /* up_fullcontextrestore() should not return but could if the software
   * interrupts are disabled.
   */

  PANIC();
}
Пример #10
0
void _exit(int status)
{
  FAR struct tcb_s* tcb;

  /* Disable interrupts.  Interrupts will remain disabled until
   * the new task is resumed below.
   */

  (void)irqsave();

  slldbg("TCB=%p exiting\n", tcb);

#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
  lldbg("Other tasks:\n");
  sched_foreach(_up_dumponexit, NULL);
#endif

  /* Destroy the task at the head of the ready to run list. */

  (void)task_exit();

  /* Now, perform the context switch to the new ready-to-run task at the
   * head of the list.
   */

  tcb = (FAR struct tcb_s*)g_readytorun.head;
  slldbg("New Active Task TCB=%p\n", tcb);

#ifdef CONFIG_ARCH_ADDRENV
  /* Make sure that the address environment for the previously running
   * task is closed down gracefully (data caches dump, MMU flushed) and
   * set up the address environment for the new thread at the head of
   * the ready-to-run list.
   */

  (void)group_addrenv(tcb);
#endif

  /* Then switch contexts */

  RESTORE_USERCONTEXT(tcb);
}
Пример #11
0
void _exit(int status)
{
  struct tcb_s *tcb;

  /* Make sure that we are in a critical section with local interrupts.
   * The IRQ state will be restored when the next task is started.
   */

  (void)enter_critical_section();

  sinfo("TCB=%p exiting\n", this_task());

#ifdef CONFIG_DUMP_ON_EXIT
  sinfo("Other tasks:\n");
  sched_foreach(_up_dumponexit, NULL);
#endif

  /* Destroy the task at the head of the ready to run list. */

  (void)task_exit();

  /* Now, perform the context switch to the new ready-to-run task at the
   * head of the list.
   */

  tcb = this_task();

#ifdef CONFIG_ARCH_ADDRENV
  /* Make sure that the address environment for the previously running
   * task is closed down gracefully (data caches dump, MMU flushed) and
   * set up the address environment for the new thread at the head of
   * the ready-to-run list.
   */

  (void)group_addrenv(tcb);
#endif

  /* Then switch contexts */

  up_fullcontextrestore(tcb->xcp.regs);
}
Пример #12
0
static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
                          FAR struct fs_dirent_s *dir)
{
  FAR struct procfs_level0_s *level0;
  FAR struct procfs_dir_priv_s *dirpriv;
  FAR void *priv = NULL;
  irqstate_t flags;

  fvdbg("relpath: \"%s\"\n", relpath ? relpath : "NULL");
  DEBUGASSERT(mountpt && relpath && dir && !dir->u.procfs);

  /* The relative must be either:
   *
   * ""      - The top level directory of task/thread IDs
   * "<pid>" - The sub-directory of task/thread attributes
   */

  if (!relpath || relpath[0] == '\0')
    {
      /* The path refers to the top level directory.  Allocate the level0
       * dirent structure.
       */

      level0 = (FAR struct procfs_level0_s *)
         kmm_zalloc(sizeof(struct procfs_level0_s));

      if (!level0)
        {
          fdbg("ERROR: Failed to allocate the level0 directory structure\n");
          return -ENOMEM;
        }

      /* Take a snapshot of all currently active tasks.  Any new tasks
       * added between the opendir() and closedir() call will not be
       * visible.
       *
       * NOTE that interrupts must be disabled throughout the traversal.
       */

#ifndef CONFIG_FS_PROCFS_EXCLUDE_PROCESS
      flags = irqsave();
      sched_foreach(procfs_enum, level0);
      irqrestore(flags);
#else
      level0->base.index = 0;
      level0->base.nentries = 0;
#endif

      /* Initialze lastread entries */

      level0->lastread = "";
      level0->lastlen = 0;
      level0->base.procfsentry = NULL;

      priv = (FAR void *)level0;
    }
  else
    {
      int x, ret;
      int len = strlen(relpath);

      /* Search the static array of procfs_entries */

      for (x = 0; x < g_procfsentrycount; x++)
        {
          /* Test if the path matches this entry's specification */

          if (match(g_procfsentries[x].pathpattern, relpath))
            {
              /* Match found!  Call the handler's opendir routine.  If successful,
               * this opendir routine will create an entry derived from struct
               * procfs_dir_priv_s as dir->u.procfs.
               */

              DEBUGASSERT(g_procfsentries[x].ops && g_procfsentries[x].ops->opendir);
              ret = g_procfsentries[x].ops->opendir(relpath, dir);

              if (ret == OK)
                {
                  DEBUGASSERT(dir->u.procfs);

                  /* Set the procfs_entry handler */

                  dirpriv = (FAR struct procfs_dir_priv_s *)dir->u.procfs;
                  dirpriv->procfsentry = &g_procfsentries[x];
                }

              return ret;
            }

            /* Test for a sub-string match (e.g. "ls /proc/fs") */

          else if (strncmp(g_procfsentries[x].pathpattern, relpath, len) == 0)
            {
              FAR struct procfs_level1_s *level1;

              /* Doing an intermediate directory search */

              /* The path refers to the top level directory.  Allocate the level0
               * dirent structure.
               */

              level1 = (FAR struct procfs_level1_s *)
                 kmm_zalloc(sizeof(struct procfs_level1_s));

              if (!level1)
                {
                  fdbg("ERROR: Failed to allocate the level0 directory structure\n");
                  return -ENOMEM;
                }

              level1->base.level = 1;
              level1->base.index = x;
              level1->firstindex = x;
              level1->subdirlen = len;
              level1->lastread = "";
              level1->lastlen = 0;
              level1->base.procfsentry = NULL;

              priv = (FAR void *)level1;
              break;
            }
        }
    }

  dir->u.procfs = priv;
  return OK;
}
Пример #13
0
int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
  nsh_output(vtbl, "PID   PRI SCHD TYPE   NP STATE    NAME\n");
  sched_foreach(ps_task, vtbl);
  return OK;
}