Blame view

RIOT/tests/thread_flood/main.c 1.13 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  /*
   * Copyright (C) 2015 Hamburg University of Applied Sciences
   *
   * This file is subject to the terms and conditions of the GNU Lesser
   * General Public License v2.1. See the file LICENSE in the top level
   * directory for more details.
   */
  
  /**
   * @ingroup tests
   * @{
   *
   * @file
   * @brief Thread flooding test.
   *
   * Spawns sleeping threads till the scheduler's capacity is exhausted.
   *
   * @author  Andreas "Paul" Pauli <andreas.pauli@haw-hamburg.de>
   *
   * @}
   */
  
  #include <errno.h>
  #include <stdio.h>
  #include "thread.h"
  
  /* One stack for all threads. DON'T TRY THIS AT HOME!! */
  static char dummy_stack[THREAD_STACKSIZE_DEFAULT];
  
  static void *thread_func(void *arg)
  {
      return arg;
  }
  
  int main(void)
  {
      kernel_pid_t thr_id = KERNEL_PID_UNDEF;
  
      puts("Start spawning\n");
      do {
          thr_id = thread_create(
              dummy_stack, sizeof(dummy_stack),
              THREAD_PRIORITY_MAIN - 1,
              THREAD_CREATE_SLEEPING | THREAD_CREATE_STACKTEST,
              thread_func, NULL, "dummy");
      } while (-EOVERFLOW != thr_id);
  
      if (-EOVERFLOW == thr_id) {
          puts("Thread creation successful aborted\n");
      }
  
      return 0;
  }