Now uses thread::user_stack_size instead of STACK_SIZE. This also fixes a
potential bug if MAIN_STACK_SIZE and STACK_SIZE would have been different. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9190 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -222,7 +222,7 @@ arch_thread_dump_info(void *info)
|
|||||||
void
|
void
|
||||||
arch_thread_enter_uspace(struct thread *t, addr_t entry, void *args1, void *args2)
|
arch_thread_enter_uspace(struct thread *t, addr_t entry, void *args1, void *args2)
|
||||||
{
|
{
|
||||||
addr_t ustack_top = t->user_stack_base + STACK_SIZE;
|
addr_t ustack_top = t->user_stack_base + t->user_stack_size;
|
||||||
|
|
||||||
TRACE(("arch_thread_enter_uspace: entry 0x%lx, args %p %p, ustack_top 0x%lx\n",
|
TRACE(("arch_thread_enter_uspace: entry 0x%lx, args %p %p, ustack_top 0x%lx\n",
|
||||||
entry, args1, args2, ustack_top));
|
entry, args1, args2, ustack_top));
|
||||||
|
|||||||
@@ -510,12 +510,13 @@ team_create_team2(void *args)
|
|||||||
|
|
||||||
// create an initial primary stack region
|
// create an initial primary stack region
|
||||||
|
|
||||||
// ToDo: make ENV_SIZE variable?
|
// ToDo: make ENV_SIZE variable and put it on the heap?
|
||||||
// ToDo: we could reserve the whole USER_STACK_REGION upfront...
|
// ToDo: we could reserve the whole USER_STACK_REGION upfront...
|
||||||
|
|
||||||
totalSize = PAGE_ALIGN(MAIN_THREAD_STACK_SIZE + TLS_SIZE + ENV_SIZE +
|
totalSize = PAGE_ALIGN(MAIN_THREAD_STACK_SIZE + TLS_SIZE + ENV_SIZE +
|
||||||
get_arguments_data_size(teamArgs->args, teamArgs->argc));
|
get_arguments_data_size(teamArgs->args, teamArgs->argc));
|
||||||
t->user_stack_base = USER_STACK_REGION + USER_STACK_REGION_SIZE - totalSize;
|
t->user_stack_base = USER_STACK_REGION + USER_STACK_REGION_SIZE - totalSize;
|
||||||
|
t->user_stack_size = MAIN_THREAD_STACK_SIZE;
|
||||||
// the exact location at the end of the user stack region
|
// the exact location at the end of the user stack region
|
||||||
|
|
||||||
sprintf(ustack_name, "%s_main_stack", team->name);
|
sprintf(ustack_name, "%s_main_stack", team->name);
|
||||||
@@ -542,7 +543,7 @@ team_create_team2(void *args)
|
|||||||
}
|
}
|
||||||
uargs[arg_cnt] = NULL;
|
uargs[arg_cnt] = NULL;
|
||||||
|
|
||||||
team->user_env_base = t->user_stack_base + STACK_SIZE + TLS_SIZE;
|
team->user_env_base = t->user_stack_base + t->user_stack_size + TLS_SIZE;
|
||||||
uenv = (char **)team->user_env_base;
|
uenv = (char **)team->user_env_base;
|
||||||
udest = (char *)team->user_env_base + ENV_SIZE - 1;
|
udest = (char *)team->user_env_base + ENV_SIZE - 1;
|
||||||
|
|
||||||
|
|||||||
@@ -351,11 +351,12 @@ create_thread(const char *name, team_id teamID, thread_entry_func entry,
|
|||||||
// the stack will be between USER_STACK_REGION and the main thread stack area
|
// the stack will be between USER_STACK_REGION and the main thread stack area
|
||||||
// (the user stack of the main thread is created in team_create_team())
|
// (the user stack of the main thread is created in team_create_team())
|
||||||
t->user_stack_base = USER_STACK_REGION;
|
t->user_stack_base = USER_STACK_REGION;
|
||||||
|
t->user_stack_size = STACK_SIZE;
|
||||||
|
|
||||||
snprintf(stack_name, B_OS_NAME_LENGTH, "%s_%lx_stack", name, t->id);
|
snprintf(stack_name, B_OS_NAME_LENGTH, "%s_%lx_stack", name, t->id);
|
||||||
t->user_stack_region_id = create_area_etc(team, stack_name,
|
t->user_stack_region_id = create_area_etc(team, stack_name,
|
||||||
(void **)&t->user_stack_base, B_BASE_ADDRESS,
|
(void **)&t->user_stack_base, B_BASE_ADDRESS,
|
||||||
STACK_SIZE + TLS_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
|
t->user_stack_size + TLS_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
|
||||||
if (t->user_stack_region_id < 0) {
|
if (t->user_stack_region_id < 0) {
|
||||||
// great, we have a fully running thread without a stack
|
// great, we have a fully running thread without a stack
|
||||||
dprintf("create_thread: unable to create user stack!\n");
|
dprintf("create_thread: unable to create user stack!\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user