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:
Axel Dörfler
2004-10-04 22:41:34 +00:00
parent 2130a091c3
commit 0f5095f9f9
3 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -222,7 +222,7 @@ arch_thread_dump_info(void *info)
void
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",
entry, args1, args2, ustack_top));
+6 -5
View File
@@ -510,12 +510,13 @@ team_create_team2(void *args)
// 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...
totalSize = PAGE_ALIGN(MAIN_THREAD_STACK_SIZE + TLS_SIZE + ENV_SIZE +
get_arguments_data_size(teamArgs->args, teamArgs->argc));
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
sprintf(ustack_name, "%s_main_stack", team->name);
@@ -542,7 +543,7 @@ team_create_team2(void *args)
}
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;
udest = (char *)team->user_env_base + ENV_SIZE - 1;
@@ -954,7 +955,7 @@ sys_setenv(const char *name, const char *value, int overwrite)
RELEASE_TEAM_LOCK();
restore_interrupts(state);
return rc;
}
@@ -970,7 +971,7 @@ sys_getenv(const char *name, char **value)
int rc = -1;
// ToDo: please put me out of the kernel into libroot.so!
state = disable_interrupts();
GRAB_TEAM_LOCK();
@@ -985,7 +986,7 @@ sys_getenv(const char *name, char **value)
}
}
}
RELEASE_TEAM_LOCK();
restore_interrupts(state);
+4 -3
View File
@@ -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 user stack of the main thread is created in team_create_team())
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);
t->user_stack_region_id = create_area_etc(team, stack_name,
(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) {
// great, we have a fully running thread without a stack
dprintf("create_thread: unable to create user stack!\n");
@@ -735,7 +736,7 @@ thread_exit(void)
// Cancel previously installed alarm timer, if any
cancel_timer(&t->alarm);
// delete the user stack region first
if (team->_aspace_id >= 0 && t->user_stack_region_id >= 0) {
region_id rid = t->user_stack_region_id;
@@ -815,7 +816,7 @@ static void
thread_kthread_exit(void)
{
struct thread *t = thread_get_current_thread();
t->return_flags = THREAD_RETURN_EXIT;
thread_exit();
}