1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

tests: Cleanup access to internal variables

Replace direct accesses to sched_active_thread and sched_active_pid with
the helper functions thread_getpid() and thread_get_active(). This serves
two purposes:

1. It makes accidental writes to those variable from outside core less likely.
2. Casting off the volatile qualifier is now well contained to those two
   functions
This commit is contained in:
Marian Buschsieweke 2020-08-23 21:28:33 +02:00
parent 659c351c02
commit eb1279005c
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F
37 changed files with 44 additions and 49 deletions

View File

@ -62,7 +62,7 @@ int main(void)
{ {
puts("Runtime of Selected Core API functions\n"); puts("Runtime of Selected Core API functions\n");
t = (thread_t *)sched_active_thread; t = thread_get_active();
BENCHMARK_FUNC("nop loop", BENCH_RUNS, __asm__ volatile ("nop")); BENCHMARK_FUNC("nop loop", BENCH_RUNS, __asm__ volatile ("nop"));
puts(""); puts("");

View File

@ -62,7 +62,7 @@ int main(void)
NULL, NULL,
"second_thread"); "second_thread");
thread_t *tcb = (thread_t *)sched_threads[other]; thread_t *tcb = thread_get(other);
xtimer_t timer; xtimer_t timer;
timer.callback = _timer_callback; timer.callback = _timer_callback;

View File

@ -28,8 +28,6 @@
#define THREAD_NUMOF (5U) #define THREAD_NUMOF (5U)
#define THREAD_FIRSTGROUP_NUMOF (3U) #define THREAD_FIRSTGROUP_NUMOF (3U)
extern volatile thread_t *sched_active_thread;
static char stacks[THREAD_NUMOF][THREAD_STACKSIZE_MAIN]; static char stacks[THREAD_NUMOF][THREAD_STACKSIZE_MAIN];
static const char prios[THREAD_NUMOF] = {THREAD_PRIORITY_MAIN - 1, 4, 0, 2, 1}; static const char prios[THREAD_NUMOF] = {THREAD_PRIORITY_MAIN - 1, 4, 0, 2, 1};
@ -40,7 +38,7 @@ static cond_t testcond;
static void *lockme(void *arg) static void *lockme(void *arg)
{ {
(void)arg; (void)arg;
volatile thread_t *t = sched_active_thread; thread_t *t = thread_get_active();
mutex_lock(&testlock); mutex_lock(&testlock);
printf("T%i (prio %i): waiting on condition variable now\n", printf("T%i (prio %i): waiting on condition variable now\n",

View File

@ -75,7 +75,7 @@ int main(void)
} }
/* save the pid of main thread */ /* save the pid of main thread */
p_main = sched_active_pid; p_main = thread_getpid();
printf("\n+--------Starting Measurements--------+\n"); printf("\n+--------Starting Measurements--------+\n");

View File

@ -79,7 +79,7 @@ int main(void)
{ {
hmc5883l_t dev; hmc5883l_t dev;
p_main = sched_active_pid; p_main = thread_getpid();
puts("HMC5883L magnetometer driver test application\n"); puts("HMC5883L magnetometer driver test application\n");
puts("Initializing HMC5883L sensor"); puts("Initializing HMC5883L sensor");

View File

@ -66,7 +66,7 @@ int main(void)
{ {
itg320x_t dev; itg320x_t dev;
p_main = sched_active_pid; p_main = thread_getpid();
puts("ITG320X gyroscope driver test application\n"); puts("ITG320X gyroscope driver test application\n");
puts("Initializing ITG320X sensor"); puts("Initializing ITG320X sensor");

View File

@ -122,7 +122,7 @@ int main(void)
#ifdef MODULE_QMC5883L_INT #ifdef MODULE_QMC5883L_INT
/* safe a reference to the main thread TCB so we can wait for flags */ /* safe a reference to the main thread TCB so we can wait for flags */
if (qmc5883l_params[0].pin_drdy != GPIO_UNDEF) { if (qmc5883l_params[0].pin_drdy != GPIO_UNDEF) {
_tmain = (thread_t *)thread_get(thread_getpid()); _tmain = thread_get_active();
if (qmc5883l_init_int(&_dev, _on_drdy, NULL) != QMC5883L_OK) { if (qmc5883l_init_int(&_dev, _on_drdy, NULL) != QMC5883L_OK) {
puts("Error: unable to configure interrupt callback"); puts("Error: unable to configure interrupt callback");

View File

@ -72,7 +72,7 @@ static void *_cnt_thread(void *arg)
int main(void) int main(void)
{ {
/* setup */ /* setup */
_thread_main = (thread_t *)thread_get(thread_getpid()); _thread_main = thread_get_active();
puts("[START] event_wait_timeout test application.\n"); puts("[START] event_wait_timeout test application.\n");

View File

@ -92,7 +92,7 @@ void _tests_init(void)
_mock_netif->ipv6.addrs_flags[0] &= ~GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_MASK; _mock_netif->ipv6.addrs_flags[0] &= ~GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_MASK;
_mock_netif->ipv6.addrs_flags[0] |= GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID; _mock_netif->ipv6.addrs_flags[0] |= GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID;
gnrc_netreg_entry_init_pid(&dumper, GNRC_NETREG_DEMUX_CTX_ALL, gnrc_netreg_entry_init_pid(&dumper, GNRC_NETREG_DEMUX_CTX_ALL,
sched_active_pid); thread_getpid());
gnrc_netreg_register(GNRC_NETTYPE_NDP, &dumper); gnrc_netreg_register(GNRC_NETTYPE_NDP, &dumper);
} }

View File

@ -108,7 +108,7 @@ void _tests_init(void)
_mock_netif = &_netif; _mock_netif = &_netif;
expect(res == 0); expect(res == 0);
gnrc_netreg_entry_init_pid(&dumper, GNRC_NETREG_DEMUX_CTX_ALL, gnrc_netreg_entry_init_pid(&dumper, GNRC_NETREG_DEMUX_CTX_ALL,
sched_active_pid); thread_getpid());
gnrc_netreg_register(GNRC_NETTYPE_NDP, &dumper); gnrc_netreg_register(GNRC_NETTYPE_NDP, &dumper);
} }

View File

@ -1275,7 +1275,7 @@ static void init_pkt_handler(void)
{ {
msg_init_queue(msg_queue_main, MSG_QUEUE_SIZE); msg_init_queue(msg_queue_main, MSG_QUEUE_SIZE);
gnrc_netreg_entry_init_pid(&netreg_entry, GNRC_NETREG_DEMUX_CTX_ALL, gnrc_netreg_entry_init_pid(&netreg_entry, GNRC_NETREG_DEMUX_CTX_ALL,
sched_active_pid); thread_getpid());
gnrc_netreg_register(GNRC_NETTYPE_NDP, &netreg_entry); gnrc_netreg_register(GNRC_NETTYPE_NDP, &netreg_entry);
netdev_test_setup(&dev, NULL); netdev_test_setup(&dev, NULL);
netdev_test_set_get_cb(&dev, NETOPT_ADDRESS_LONG, netdev_test_set_get_cb(&dev, NETOPT_ADDRESS_LONG,

View File

@ -330,7 +330,7 @@ static void test_rbuf_add__success_complete(void)
msg_t msg = { .type = 0U }; msg_t msg = { .type = 0U };
gnrc_netreg_entry_t reg = GNRC_NETREG_ENTRY_INIT_PID( gnrc_netreg_entry_t reg = GNRC_NETREG_ENTRY_INIT_PID(
GNRC_NETREG_DEMUX_CTX_ALL, GNRC_NETREG_DEMUX_CTX_ALL,
sched_active_pid thread_getpid()
); );
gnrc_netreg_register(TEST_DATAGRAM_NETTYPE, &reg); gnrc_netreg_register(TEST_DATAGRAM_NETTYPE, &reg);

View File

@ -30,7 +30,7 @@ void _net_init(void)
{ {
msg_init_queue(_msg_queue, _MSG_QUEUE_SIZE); msg_init_queue(_msg_queue, _MSG_QUEUE_SIZE);
gnrc_netreg_entry_init_pid(&_ip_handler, GNRC_NETREG_DEMUX_CTX_ALL, gnrc_netreg_entry_init_pid(&_ip_handler, GNRC_NETREG_DEMUX_CTX_ALL,
sched_active_pid); thread_getpid());
} }
void _prepare_send_checks(void) void _prepare_send_checks(void)

View File

@ -35,7 +35,7 @@ void _net_init(void)
{ {
msg_init_queue(_msg_queue, _MSG_QUEUE_SIZE); msg_init_queue(_msg_queue, _MSG_QUEUE_SIZE);
gnrc_netreg_entry_init_pid(&_udp_handler, GNRC_NETREG_DEMUX_CTX_ALL, gnrc_netreg_entry_init_pid(&_udp_handler, GNRC_NETREG_DEMUX_CTX_ALL,
sched_active_pid); thread_getpid());
} }
void _prepare_send_checks(void) void _prepare_send_checks(void)

View File

@ -139,7 +139,7 @@ static int _netdev_send(netdev_t *dev, const iolist_t *iolist)
void _net_init(void) void _net_init(void)
{ {
msg_init_queue(_msg_queue, _MSG_QUEUE_SIZE); msg_init_queue(_msg_queue, _MSG_QUEUE_SIZE);
_check_pid = sched_active_pid; _check_pid = thread_getpid();
netdev_test_setup(&netdev, NULL); netdev_test_setup(&netdev, NULL);
netdev_test_set_get_cb(&netdev, NETOPT_SRC_LEN, _get_src_len); netdev_test_set_get_cb(&netdev, NETOPT_SRC_LEN, _get_src_len);

View File

@ -1073,7 +1073,7 @@ static void *_server_func(void *arg)
(void)arg; (void)arg;
msg_init_queue(_server_msg_queue, _MSG_QUEUE_SIZE); msg_init_queue(_server_msg_queue, _MSG_QUEUE_SIZE);
_server = sched_active_pid; _server = thread_getpid();
while (1) { while (1) {
msg_t msg; msg_t msg;
@ -1139,7 +1139,7 @@ static void *_client_func(void *arg)
(void)arg; (void)arg;
msg_init_queue(_client_msg_queue, _MSG_QUEUE_SIZE); msg_init_queue(_client_msg_queue, _MSG_QUEUE_SIZE);
_client = sched_active_pid; _client = thread_getpid();
while (1) { while (1) {
msg_t msg; msg_t msg;

View File

@ -142,7 +142,7 @@ static int _netdev_send(netdev_t *dev, const iolist_t *iolist)
void _net_init(void) void _net_init(void)
{ {
msg_init_queue(_msg_queue, _MSG_QUEUE_SIZE); msg_init_queue(_msg_queue, _MSG_QUEUE_SIZE);
_check_pid = sched_active_pid; _check_pid = thread_getpid();
netdev_test_setup(&netdev, NULL); netdev_test_setup(&netdev, NULL);
netdev_test_set_get_cb(&netdev, NETOPT_SRC_LEN, _get_src_len); netdev_test_set_get_cb(&netdev, NETOPT_SRC_LEN, _get_src_len);

View File

@ -24,8 +24,6 @@
#define THREAD_NUMOF (5U) #define THREAD_NUMOF (5U)
extern volatile thread_t *sched_active_thread;
static char stacks[THREAD_NUMOF][THREAD_STACKSIZE_MAIN]; static char stacks[THREAD_NUMOF][THREAD_STACKSIZE_MAIN];
static const char prios[THREAD_NUMOF] = {THREAD_PRIORITY_MAIN - 1, 4, 0, 2, 1}; static const char prios[THREAD_NUMOF] = {THREAD_PRIORITY_MAIN - 1, 4, 0, 2, 1};
@ -35,7 +33,7 @@ static mutex_t testlock;
static void *lockme(void *arg) static void *lockme(void *arg)
{ {
(void)arg; (void)arg;
volatile thread_t *t = sched_active_thread; thread_t *t = thread_get_active();
printf("T%i (prio %i): trying to lock mutex now\n", printf("T%i (prio %i): trying to lock mutex now\n",
(int)t->pid, (int)t->priority); (int)t->pid, (int)t->priority);

View File

@ -135,7 +135,7 @@ static int test_receive(void)
uint8_t *rcv_payload = _tmp + sizeof(ethernet_hdr_t); uint8_t *rcv_payload = _tmp + sizeof(ethernet_hdr_t);
gnrc_pktsnip_t *pkt, *hdr; gnrc_pktsnip_t *pkt, *hdr;
gnrc_netreg_entry_t me = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL, gnrc_netreg_entry_t me = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL,
sched_active_pid); thread_getpid());
msg_t msg; msg_t msg;
if (_dev.netdev.event_callback == NULL) { if (_dev.netdev.event_callback == NULL) {

View File

@ -312,7 +312,7 @@ int main(void)
puts("NimBLE L2CAP test application"); puts("NimBLE L2CAP test application");
/* save context of the main thread */ /* save context of the main thread */
_main = (thread_t *)thread_get(thread_getpid()); _main = thread_get_active();
/* initialize buffers and setup the test environment */ /* initialize buffers and setup the test environment */
res = os_mempool_init(&_coc_mempool, MBUFCNT, MBUFSIZE, _coc_mem, "appbuf"); res = os_mempool_init(&_coc_mempool, MBUFCNT, MBUFSIZE, _coc_mem, "appbuf");

View File

@ -82,14 +82,14 @@ static struct {
*/ */
static void _sched_statistics_trigger(void) static void _sched_statistics_trigger(void)
{ {
sched_statistics_cb(sched_active_pid, sched_active_pid); sched_statistics_cb(thread_getpid(), thread_getpid());
} }
static xtimer_ticks32_t _sched_ticks(void) static xtimer_ticks32_t _sched_ticks(void)
{ {
_sched_statistics_trigger(); _sched_statistics_trigger();
xtimer_ticks32_t runtime_ticks = { xtimer_ticks32_t runtime_ticks = {
.ticks32 = sched_pidlist[sched_active_pid].runtime_ticks .ticks32 = sched_pidlist[thread_getpid()].runtime_ticks
}; };
return runtime_ticks; return runtime_ticks;
} }

View File

@ -65,7 +65,7 @@ int main(void)
"On failure, this test prints an error message.\n\n"); "On failure, this test prints an error message.\n\n");
printf("testing periph_timer %u, freq %lu\n", TEST_TIMER_DEV, TEST_TIMER_FREQ); printf("testing periph_timer %u, freq %lu\n", TEST_TIMER_DEV, TEST_TIMER_FREQ);
timer_init(TEST_TIMER_DEV, TEST_TIMER_FREQ, cb, (thread_t *)sched_active_thread); timer_init(TEST_TIMER_DEV, TEST_TIMER_FREQ, cb, thread_get_active());
uint32_t interval = 100; uint32_t interval = 100;
while (interval--) { while (interval--) {

View File

@ -63,8 +63,8 @@ static mutex_t stdout_mutex = MUTEX_INIT;
do { \ do { \
mutex_lock(&stdout_mutex); \ mutex_lock(&stdout_mutex); \
printf("%c%" PRIkernel_pid " (prio=%u): " FMT "\n", \ printf("%c%" PRIkernel_pid " (prio=%u): " FMT "\n", \
__func__[0], sched_active_pid, \ __func__[0], thread_getpid(), \
sched_active_thread->priority, \ thread_get_active()->priority, \
(int)__VA_ARGS__); \ (int)__VA_ARGS__); \
mutex_unlock(&stdout_mutex); \ mutex_unlock(&stdout_mutex); \
} while (0) } while (0)

View File

@ -25,8 +25,6 @@
#define THREAD_NUMOF (5U) #define THREAD_NUMOF (5U)
extern volatile thread_t *sched_active_thread;
static char stacks[THREAD_NUMOF][THREAD_STACKSIZE_MAIN]; static char stacks[THREAD_NUMOF][THREAD_STACKSIZE_MAIN];
static const char prios[THREAD_NUMOF] = {THREAD_PRIORITY_MAIN - 1, 4, 5, 2, 4}; static const char prios[THREAD_NUMOF] = {THREAD_PRIORITY_MAIN - 1, 4, 5, 2, 4};
@ -36,7 +34,7 @@ static rmutex_t testlock;
static void lock_recursive(char n, char depth) static void lock_recursive(char n, char depth)
{ {
volatile thread_t *t = sched_active_thread; thread_t *t = thread_get_active();
printf("T%i (prio %i, depth %i): trying to lock rmutex now\n", printf("T%i (prio %i, depth %i): trying to lock rmutex now\n",
(int)t->pid, (int)t->priority, (int)n); (int)t->pid, (int)t->priority, (int)n);

View File

@ -25,8 +25,6 @@
#define THREAD_NUMOF (5U) #define THREAD_NUMOF (5U)
extern volatile thread_t *sched_active_thread;
static char stacks[THREAD_NUMOF][THREAD_STACKSIZE_MAIN]; static char stacks[THREAD_NUMOF][THREAD_STACKSIZE_MAIN];
static const char prios[THREAD_NUMOF] = {THREAD_PRIORITY_MAIN - 1, 4, 5, 2, 4}; static const char prios[THREAD_NUMOF] = {THREAD_PRIORITY_MAIN - 1, 4, 5, 2, 4};
@ -36,7 +34,7 @@ static rmutex_t testlock;
static void lock_recursive(char n, char depth) static void lock_recursive(char n, char depth)
{ {
volatile thread_t *t = sched_active_thread; thread_t *t = thread_get_active();
printf("T%i (prio %i, depth %i): trying to lock rmutex now\n", printf("T%i (prio %i, depth %i): trying to lock rmutex now\n",
(int)t->pid, (int)t->priority, (int)n); (int)t->pid, (int)t->priority, (int)n);

View File

@ -27,7 +27,9 @@
#include "sched.h" #include "sched.h"
#include "socket_zep.h" #include "socket_zep.h"
#include "socket_zep_params.h" #include "socket_zep_params.h"
#include "socket_zep_params.h"
#include "test_utils/expect.h" #include "test_utils/expect.h"
#include "thread.h"
#include "msg.h" #include "msg.h"
#include "od.h" #include "od.h"
@ -106,7 +108,7 @@ int main(void)
{ {
puts("Socket ZEP device driver test"); puts("Socket ZEP device driver test");
msg_init_queue(_msg_queue, MSG_QUEUE_SIZE); msg_init_queue(_msg_queue, MSG_QUEUE_SIZE);
_main_pid = sched_active_pid; _main_pid = thread_getpid();
test_init(); test_init();
test_send__iolist_NULL(); test_send__iolist_NULL();

View File

@ -21,6 +21,7 @@
#include <stdio.h> #include <stdio.h>
#include "xtimer.h" #include "xtimer.h"
#include "thread.h"
#include "thread_flags.h" #include "thread_flags.h"
#define TIMEOUT (100UL * US_PER_MS) #define TIMEOUT (100UL * US_PER_MS)
@ -29,7 +30,7 @@
static void time_evt(void *arg) static void time_evt(void *arg)
{ {
thread_flags_set((thread_t *)arg, 0x1); thread_flags_set(arg, 0x1);
} }
int main(void) int main(void)
@ -37,7 +38,7 @@ int main(void)
puts("START"); puts("START");
xtimer_t timer; xtimer_t timer;
timer.callback = time_evt; timer.callback = time_evt;
timer.arg = (void *)sched_active_thread; timer.arg = thread_get_active();
uint32_t last = xtimer_now_usec(); uint32_t last = xtimer_now_usec();
puts("Test setting thread flags from (x)timer callback"); puts("Test setting thread flags from (x)timer callback");

View File

@ -85,7 +85,7 @@ void *thread3(void *arg)
int main(void) int main(void)
{ {
p_main = sched_active_pid; p_main = thread_getpid();
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1, p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
thread1, NULL, "nr1"); thread1, NULL, "nr1");

View File

@ -86,7 +86,7 @@ int main(void)
random_init(timer_read(TIMER_DEV(0))); random_init(timer_read(TIMER_DEV(0)));
puts("Test is \"successful\" if it runs forever without halting\n" puts("Test is \"successful\" if it runs forever without halting\n"
"on any of the assertion in this file\n"); "on any of the assertion in this file\n");
_pid_main = sched_active_pid; _pid_main = thread_getpid();
puts("I will try to trigger an interrupt at random intervals. When an\n" puts("I will try to trigger an interrupt at random intervals. When an\n"
"interrupt is fired while ISR is disable in the thread_yield_higher()\n" "interrupt is fired while ISR is disable in the thread_yield_higher()\n"

View File

@ -55,7 +55,7 @@ void *sender_thread(void *arg)
int main(void) int main(void)
{ {
msg_t msg; msg_t msg;
p_recv = sched_active_pid; p_recv = thread_getpid();
msg_t msg_q[1]; msg_t msg_q[1];
msg_init_queue(msg_q, 1); msg_init_queue(msg_q, 1);

View File

@ -55,7 +55,7 @@ void *thread1(void *arg)
int main(void) int main(void)
{ {
msg_t msg; msg_t msg;
p_recv = sched_active_pid; p_recv = thread_getpid();
p_send = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1, p_send = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,

View File

@ -107,7 +107,7 @@ int main(void)
msg_bus_init(&my_bus); msg_bus_init(&my_bus);
p_main = sched_active_pid; p_main = thread_getpid();
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 3, p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 3,
THREAD_CREATE_STACKTEST, thread1, &my_bus, "nr1"); THREAD_CREATE_STACKTEST, thread1, &my_bus, "nr1");
p2 = thread_create(t2_stack, sizeof(t2_stack), THREAD_PRIORITY_MAIN - 2, p2 = thread_create(t2_stack, sizeof(t2_stack), THREAD_PRIORITY_MAIN - 2,

View File

@ -54,7 +54,7 @@ int main(void)
puts("START"); puts("START");
msg_t msg; msg_t msg;
p_main = sched_active_pid; p_main = thread_getpid();
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1, p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_STACKTEST, sub_thread, "nr1", "nr1"); THREAD_CREATE_STACKTEST, sub_thread, "nr1", "nr1");

View File

@ -48,7 +48,7 @@ static void _thread_wake_wo_yield(kernel_pid_t pid)
{ {
unsigned old_state = irq_disable(); unsigned old_state = irq_disable();
thread_t *other_thread = (thread_t *) thread_get(pid); thread_t *other_thread = thread_get(pid);
sched_set_status(other_thread, STATUS_RUNNING); sched_set_status(other_thread, STATUS_RUNNING);

View File

@ -68,7 +68,7 @@ int main(void)
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
trickle_start(sched_active_pid, &trickle, TRICKLE_MSG, TR_IMIN, trickle_start(thread_getpid(), &trickle, TRICKLE_MSG, TR_IMIN,
TR_IDOUBLINGS, TR_REDCONST); TR_IDOUBLINGS, TR_REDCONST);
puts("[START]"); puts("[START]");

View File

@ -106,7 +106,7 @@ static void *run_get(void *arg)
static void tests_core_ringbuffer(void) static void tests_core_ringbuffer(void)
{ {
pid_add = sched_active_pid; pid_add = thread_getpid();
pid_get = thread_create(stack_get, sizeof (stack_get), pid_get = thread_create(stack_get, sizeof (stack_get),
THREAD_PRIORITY_MAIN, THREAD_PRIORITY_MAIN,
THREAD_CREATE_SLEEPING | THREAD_CREATE_STACKTEST, THREAD_CREATE_SLEEPING | THREAD_CREATE_STACKTEST,

View File

@ -37,7 +37,7 @@ int main(void)
tmsg.type = 42; tmsg.type = 42;
puts("[START]"); puts("[START]");
for (unsigned i = 0; i < TEST_COUNT; i++) { for (unsigned i = 0; i < TEST_COUNT; i++) {
xtimer_set_msg(&t, TEST_PERIOD + offset, &tmsg, sched_active_pid); xtimer_set_msg(&t, TEST_PERIOD + offset, &tmsg, thread_getpid());
if (xtimer_msg_receive_timeout(&m, TEST_PERIOD) < 0) { if (xtimer_msg_receive_timeout(&m, TEST_PERIOD) < 0) {
puts("Timeout!"); puts("Timeout!");
msg_receive(&m); msg_receive(&m);