Skip to content

Commit

Permalink
updated stack size
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajmund Szymanski committed Aug 29, 2017
1 parent 3b2c83d commit 4cf9320
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions StateOS/kernel/src/os_tsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

#include <os.h>

#define ALHI( size ) (((size_t)( size )+sizeof(stk_t)-1)&~(sizeof(stk_t)-1))
#define ALLO( size ) (((size_t)( size ) )&~(sizeof(stk_t)-1))

/* -------------------------------------------------------------------------- */
void tsk_init( tsk_t *tsk, unsigned prio, fun_t *state, stk_t *stack, unsigned size )
/* -------------------------------------------------------------------------- */
Expand All @@ -45,8 +48,8 @@ void tsk_init( tsk_t *tsk, unsigned prio, fun_t *state, stk_t *stack, unsigned s
tsk->prio = prio;
tsk->basic = prio;
tsk->state = state;
tsk->stack = (stk_t *)(((size_t)stack+sizeof(stk_t)-1)&~(sizeof(stk_t)-1));
tsk->top = (stk_t *)(((size_t)stack+size )&~(sizeof(stk_t)-1));
tsk->stack = stack;
tsk->top = (stk_t *) ALLO((size_t)stack+size);

core_ctx_init(tsk);
core_tsk_insert(tsk);
Expand All @@ -66,6 +69,8 @@ tsk_t *tsk_create( unsigned prio, fun_t *state, unsigned size )
if (size == 0)
size = OS_STACK_SIZE;

size = ALHI(size)+ALHI(sizeof(tsk_t))-sizeof(tsk);

port_sys_lock();

tsk = core_sys_alloc(sizeof(tsk_t) + size);
Expand Down

0 comments on commit 4cf9320

Please sign in to comment.