mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
* API CHANGE! changed thread_create so it allocates tcb on stack, removing first argument
This commit is contained in:
parent
f860abc408
commit
eff0b1980f
@ -34,7 +34,7 @@
|
||||
*
|
||||
* @return returns <0 on error, pid of newly created task else.
|
||||
*/
|
||||
int thread_create(tcb *cb, char *stack, int stacksize, char priority, int flags, void (*function) (void), const char* name);
|
||||
int thread_create(char *stack, int stacksize, char priority, int flags, void (*function) (void), const char* name);
|
||||
|
||||
/**
|
||||
* @brief returns the status of a process.
|
||||
|
@ -57,10 +57,7 @@ static void idle_thread(void) {
|
||||
const char *main_name = "main";
|
||||
const char *idle_name = "idle";
|
||||
|
||||
static tcb main_tcb;
|
||||
static char main_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
||||
|
||||
static tcb idle_tcb;
|
||||
static char idle_stack[KERNEL_CONF_STACKSIZE_IDLE];
|
||||
|
||||
#ifdef MODULE_AUTO_INIT
|
||||
@ -76,11 +73,11 @@ void kernel_init(void)
|
||||
|
||||
sched_init();
|
||||
|
||||
if (thread_create(&idle_tcb, idle_stack, sizeof(idle_stack), PRIORITY_IDLE, CREATE_WOUT_YIELD | CREATE_STACKTEST, idle_thread, idle_name) < 0) {
|
||||
if (thread_create(idle_stack, sizeof(idle_stack), PRIORITY_IDLE, CREATE_WOUT_YIELD | CREATE_STACKTEST, idle_thread, idle_name) < 0) {
|
||||
printf("kernel_init(): error creating idle task.\n");
|
||||
}
|
||||
|
||||
if (thread_create(&main_tcb, main_stack, sizeof(main_stack), PRIORITY_MAIN, CREATE_WOUT_YIELD | CREATE_STACKTEST, MAIN_FUNC, main_name) < 0) {
|
||||
if (thread_create(main_stack, sizeof(main_stack), PRIORITY_MAIN, CREATE_WOUT_YIELD | CREATE_STACKTEST, MAIN_FUNC, main_name) < 0) {
|
||||
printf("kernel_init(): error creating main task.\n");
|
||||
}
|
||||
|
||||
|
@ -80,13 +80,12 @@ int thread_measure_stack_usage(char* stack) {
|
||||
return space;
|
||||
}
|
||||
|
||||
int thread_create(tcb *cb, char *stack, int stacksize, char priority, int flags, void (*function) (void), const char* name)
|
||||
int thread_create(char *stack, int stacksize, char priority, int flags, void (*function) (void), const char* name)
|
||||
{
|
||||
/* stacksize must be a multitude of 4 for alignment and stacktest */
|
||||
// assert( ((stacksize & 0x03) == 0) && (stacksize > 0) );
|
||||
|
||||
// TODO: shall we autoalign the stack?
|
||||
// stacksize += 4-(~(stacksize & 0x0003));
|
||||
/* allocate our thread control block at the top of our stackspace */
|
||||
int total_stacksize = stacksize;
|
||||
stacksize -= sizeof(tcb);
|
||||
tcb *cb = (tcb*) (stack + stacksize);
|
||||
|
||||
if (priority >= SCHED_PRIO_LEVELS) {
|
||||
return -EINVAL;
|
||||
@ -130,7 +129,7 @@ int thread_create(tcb *cb, char *stack, int stacksize, char priority, int flags,
|
||||
|
||||
cb->sp = thread_stack_init(function,stack+stacksize);
|
||||
cb->stack_start = stack;
|
||||
cb->stack_size = stacksize;
|
||||
cb->stack_size = total_stacksize;
|
||||
|
||||
cb->priority = priority;
|
||||
cb->status = 0;
|
||||
|
@ -102,7 +102,6 @@ static uint64_t cc1100_watch_dog_period = 0;
|
||||
static uint16_t cc1100_event_handler_pid;
|
||||
static void cc1100_event_handler_function(void);
|
||||
|
||||
static tcb event_handler_tcb;
|
||||
static char event_handler_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -194,7 +193,7 @@ void cc1100_phy_init()
|
||||
mutex_init(&cc1100_mutex);
|
||||
|
||||
// Allocate event numbers and start cc1100 event process
|
||||
cc1100_event_handler_pid = thread_create(&event_handler_tcb, event_handler_stack, sizeof(event_handler_stack), PRIORITY_CC1100, CREATE_STACKTEST,
|
||||
cc1100_event_handler_pid = thread_create(event_handler_stack, sizeof(event_handler_stack), PRIORITY_CC1100, CREATE_STACKTEST,
|
||||
cc1100_event_handler_function, cc1100_event_handler_name);
|
||||
|
||||
// Active watchdog for the first time
|
||||
|
@ -15,7 +15,6 @@ void second_thread(void) {
|
||||
}
|
||||
}
|
||||
|
||||
tcb second_thread_tcb;
|
||||
char second_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
||||
|
||||
int main(void)
|
||||
@ -24,7 +23,7 @@ int main(void)
|
||||
|
||||
msg m;
|
||||
|
||||
int pid = thread_create(&second_thread_tcb, second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");
|
||||
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");
|
||||
|
||||
m.content.value = 1;
|
||||
|
||||
|
@ -15,7 +15,6 @@ void second_thread(void) {
|
||||
}
|
||||
}
|
||||
|
||||
tcb second_thread_tcb;
|
||||
char second_thread_stack[8192];
|
||||
|
||||
int main(void)
|
||||
@ -24,7 +23,7 @@ int main(void)
|
||||
|
||||
msg m;
|
||||
|
||||
int pid = thread_create(&second_thread_tcb, second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");
|
||||
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");
|
||||
|
||||
m.content.value = 1;
|
||||
|
||||
|
@ -19,14 +19,13 @@ void second_thread(void) {
|
||||
}
|
||||
}
|
||||
|
||||
tcb second_thread_tcb;
|
||||
char second_thread_stack[KERNEL_CONF_STACKSIZE_DEFAULT*2];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
hwtimer_init();
|
||||
|
||||
int pid = thread_create(&second_thread_tcb, second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_STACKTEST | CREATE_SLEEPING | CREATE_WOUT_YIELD, second_thread, "sleeper");
|
||||
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_STACKTEST | CREATE_SLEEPING | CREATE_WOUT_YIELD, second_thread, "sleeper");
|
||||
|
||||
if (pid < 0) {
|
||||
puts("Error creating second_thread! Stopping test.");
|
||||
|
@ -13,7 +13,6 @@ static void second_thread(void) {
|
||||
puts(" 2nd: done.");
|
||||
}
|
||||
|
||||
static tcb second_tcb;
|
||||
static char second_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
||||
|
||||
void mutex_trylock_fail(char* cmdline)
|
||||
@ -22,7 +21,7 @@ void mutex_trylock_fail(char* cmdline)
|
||||
mutex_lock(&mutex);
|
||||
|
||||
puts("main: creating thread...");
|
||||
thread_create(&second_tcb, second_stack, KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN-1, CREATE_STACKTEST, second_thread, "nr2");
|
||||
thread_create(second_stack, KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN-1, CREATE_STACKTEST, second_thread, "nr2");
|
||||
|
||||
puts("main: thread created. Unlocking mutex...");
|
||||
mutex_unlock(&mutex, true);
|
||||
|
@ -18,11 +18,10 @@ static void second_thread(void) {
|
||||
}
|
||||
|
||||
static char second_thread_stack[KERNEL_CONF_STACKSIZE_DEFAULT*2];
|
||||
static tcb second_thread_tcb;
|
||||
|
||||
void test_thread_sleep(char* line)
|
||||
{
|
||||
int pid = thread_create(&second_thread_tcb, second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_STACKTEST | CREATE_SLEEPING | CREATE_WOUT_YIELD, second_thread, "sleeper");
|
||||
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_STACKTEST | CREATE_SLEEPING | CREATE_WOUT_YIELD, second_thread, "sleeper");
|
||||
|
||||
if (pid < 0) {
|
||||
puts("Error creating second_thread! Stopping test.");
|
||||
|
@ -9,11 +9,10 @@ void second_thread(void) {
|
||||
puts("2nd: running...");
|
||||
}
|
||||
|
||||
tcb second_thread_tcb;
|
||||
char second_thread_stack[8192];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int pid = thread_create(&second_thread_tcb, second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "nr2");
|
||||
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "nr2");
|
||||
puts("Main thread exiting...");
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ int uart0_handler_pid;
|
||||
|
||||
static char buffer[UART0_BUFSIZE];
|
||||
|
||||
static tcb uart0_thread_tcb;
|
||||
static char uart0_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
||||
|
||||
static void uart0_loop() {
|
||||
@ -22,7 +21,7 @@ static void uart0_loop() {
|
||||
|
||||
void board_uart0_init() {
|
||||
ringbuffer_init(&uart0_ringbuffer, buffer, UART0_BUFSIZE);
|
||||
int pid = thread_create(&uart0_thread_tcb, uart0_thread_stack, sizeof(uart0_thread_stack), PRIORITY_MAIN-1, CREATE_STACKTEST, uart0_loop, "uart0");
|
||||
int pid = thread_create(uart0_thread_stack, sizeof(uart0_thread_stack), PRIORITY_MAIN-1, CREATE_STACKTEST, uart0_loop, "uart0");
|
||||
uart0_handler_pid = pid;
|
||||
puts("uart0_init() [OK]");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user