/* This function is executed by the first task that is started
 * by pico]OS ( see the nosInit()-call in main(), file ex_init4.c ).
 */
void firsttask(void *arg)
{
  NOSTASK_t  t;

  /* Avoid compiler warning. "arg" is the "NULL" in the nosInit()-call */
  (void) arg;

  nosPrint("First task started\n");

  /* start a second task */
  t = nosTaskCreate(secondtask, /* pointer to new task-function            */
                    "Task 2",   /* optional argument for the task-function */
                    2,          /* priority level of the new task          */
                    0,          /* stack size (0 = default size)           */
                    "task2");   /* optional name of the second task        */

  if (t == NULL)
  {
    nosPrint("Failed to start second task!\n");
  }

  for(;;)
  {
    /* print string: "Task 1" */
    nosPrint("Task 1\n");

    /* sleep (=do nothing) for one second */
    nosTaskSleep(MS(1000));
  }
}
Exemple #2
0
/*
 * Wait for another thead to terminate.
 * Not very sophisticated implementation, just loops and waits.
 */
wwd_result_t host_rtos_join_thread(host_thread_type_t* thread)
{
  while (!nosTaskUnused(*thread)) {

    nosTaskSleep(MS(10));
  }

  return WWD_SUCCESS;
}
/* This function is executed by the second task that is set up
 * in the function firsttask() by a call to nosTaskCreate()
 */
void secondtask(void *arg)
{
  char *name = (char*) arg;

  for(;;)
  {
    /* print string: "Task 2" */
    nosPrintf1("%s\n", name);

    /* sleep (=do nothing) for two seconds */
    nosTaskSleep(MS(2000));
  }
}
Exemple #4
0
/*
 * Sleep.
 */
wwd_result_t host_rtos_delay_milliseconds(uint32_t ms)
{
  nosTaskSleep(MS(ms));
  return WWD_SUCCESS;
}