Added another argument parameter for the thread creation code. Helps
implementing a more efficient on_exit_thread(). Note, this extra parameter is currently only used for user space code, not yet in the kernel; thus on_exit_thread() is not available in the kernel. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3075 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -216,16 +216,16 @@ arch_thread_dump_info(void *info)
|
||||
*/
|
||||
|
||||
void
|
||||
arch_thread_enter_uspace(struct thread *t, addr entry, void *args)
|
||||
arch_thread_enter_uspace(struct thread *t, addr entry, void *args1, void *args2)
|
||||
{
|
||||
addr ustack_top = t->user_stack_base + STACK_SIZE;
|
||||
|
||||
dprintf("arch_thread_enter_uspace: entry 0x%lx, args %p, ustack_top 0x%lx\n",
|
||||
entry, args, ustack_top);
|
||||
dprintf("arch_thread_enter_uspace: entry 0x%lx, args %p %p, ustack_top 0x%lx\n",
|
||||
entry, args1, args2, ustack_top);
|
||||
|
||||
// make sure the fpu is in a good state
|
||||
asm("fninit");
|
||||
|
||||
|
||||
// access the new stack to make sure the memory page is present
|
||||
// while interrupts are disabled.
|
||||
// XXX does this belong there, should caller take care of it?
|
||||
@@ -238,7 +238,7 @@ arch_thread_enter_uspace(struct thread *t, addr entry, void *args)
|
||||
// set the CPU dependent GDT entry for TLS
|
||||
set_tls_context(t);
|
||||
|
||||
i386_enter_uspace(entry, args, ustack_top - 4);
|
||||
i386_enter_uspace(entry, args1, args2, ustack_top - 4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -179,11 +179,12 @@ i386_uspace_exit_stub:
|
||||
i386_uspace_exit_stub_end:
|
||||
|
||||
|
||||
/* void i386_enter_uspace(addr entry, void *args, addr ustack_top); */
|
||||
/* void i386_enter_uspace(addr entry, void *args1, void *args2, addr ustack_top); */
|
||||
FUNCTION(i386_enter_uspace):
|
||||
movl 4(%esp),%eax // get entry point
|
||||
movl 8(%esp),%edx // get arguments
|
||||
movl 12(%esp),%ebx // get user stack
|
||||
movl 12(%esp),%edi
|
||||
movl 16(%esp),%ebx // get user stack
|
||||
movw $USER_DATA_SEG,%cx
|
||||
movw %cx,%ds
|
||||
movw %cx,%es
|
||||
@@ -201,9 +202,10 @@ _copy_more:
|
||||
jg _copy_more
|
||||
|
||||
// push the args onto the user stack
|
||||
movl %edx,-4(%ebx) // args
|
||||
movl %ebx,-8(%ebx) // fake return address to copied exit stub
|
||||
sub $8,%ebx
|
||||
movl %edi,-4(%ebx) // args1
|
||||
movl %edx,-8(%ebx) // args2
|
||||
movl %ebx,-12(%ebx) // fake return address to copied exit stub
|
||||
sub $12,%ebx
|
||||
|
||||
pushl $USER_DATA_SEG // user data segment
|
||||
pushl %ebx // user stack
|
||||
|
||||
@@ -247,7 +247,7 @@ int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_re
|
||||
*call_ret = user_vm_get_region_info((region_id)arg0, (vm_region_info *)arg1);
|
||||
break;
|
||||
case SYSCALL_SPAWN_THREAD:
|
||||
*call_ret = user_spawn_thread((thread_func)arg0, (const char *)arg1, (int)arg2, (void *)arg3);
|
||||
*call_ret = user_spawn_thread((thread_func)arg0, (const char *)arg1, (int)arg2, (void *)arg3, (void *)arg4);
|
||||
break;
|
||||
case SYSCALL_SET_THREAD_PRIORITY:
|
||||
*call_ret = user_set_thread_priority((thread_id)arg0, (int32)arg1);
|
||||
|
||||
@@ -490,7 +490,7 @@ team_create_team2(void *args)
|
||||
team->state = TEAM_STATE_NORMAL;
|
||||
|
||||
// jump to the entry point in user space
|
||||
arch_thread_enter_uspace(t, entry, uspa);
|
||||
arch_thread_enter_uspace(t, entry, uspa, NULL);
|
||||
|
||||
// never gets here
|
||||
return 0;
|
||||
|
||||
+11
-10
@@ -179,7 +179,7 @@ create_thread_struct(const char *name)
|
||||
t->team_next = NULL;
|
||||
t->queue_next = NULL;
|
||||
t->priority = -1;
|
||||
t->args = NULL;
|
||||
t->args1 = NULL; t->args2 = NULL;
|
||||
t->sig_pending = 0;
|
||||
t->sig_block_mask = 0;
|
||||
memset(t->sig_action, 0, 32 * sizeof(struct sigaction));
|
||||
@@ -255,7 +255,7 @@ _create_user_thread_kentry(void)
|
||||
thread->in_kernel = false;
|
||||
|
||||
// jump to the entry point in user space
|
||||
arch_thread_enter_uspace(thread, (addr)thread->entry, thread->args);
|
||||
arch_thread_enter_uspace(thread, (addr)thread->entry, thread->args1, thread->args2);
|
||||
|
||||
// never get here
|
||||
return 0;
|
||||
@@ -278,12 +278,12 @@ _create_kernel_thread_kentry(void)
|
||||
// call the entry function with the appropriate args
|
||||
func = (void *)thread->entry;
|
||||
|
||||
return func(thread->args);
|
||||
return func(thread->args1);
|
||||
}
|
||||
|
||||
|
||||
static thread_id
|
||||
create_thread(const char *name, team_id teamID, thread_func entry, void *args, int32 priority, bool kernel)
|
||||
create_thread(const char *name, team_id teamID, thread_func entry, void *args1, void *args2, int32 priority, bool kernel)
|
||||
{
|
||||
struct thread *t;
|
||||
struct team *team;
|
||||
@@ -339,7 +339,8 @@ create_thread(const char *name, team_id teamID, thread_func entry, void *args, i
|
||||
if (t->kernel_stack_region_id < 0)
|
||||
panic("_create_thread: error creating kernel stack!\n");
|
||||
|
||||
t->args = args;
|
||||
t->args1 = args1;
|
||||
t->args2 = args2;
|
||||
t->entry = entry;
|
||||
|
||||
if (kernel) {
|
||||
@@ -436,7 +437,7 @@ _dump_thread_info(struct thread *t)
|
||||
dprintf("sem_errcode: 0x%x\n", t->sem_errcode);
|
||||
dprintf("sem_flags: 0x%x\n", t->sem_flags);
|
||||
dprintf("fault_handler: %p\n", (void *)t->fault_handler);
|
||||
dprintf("args: %p\n", t->args);
|
||||
dprintf("args: %p %p\n", t->args1, t->args2);
|
||||
dprintf("entry: %p\n", (void *)t->entry);
|
||||
dprintf("team: %p\n", t->team);
|
||||
dprintf("return_code_sem: 0x%lx\n", t->return_code_sem);
|
||||
@@ -1126,7 +1127,7 @@ thread_init_percpu(int cpu_num)
|
||||
thread_id
|
||||
spawn_kernel_thread_etc(thread_func function, const char *name, int32 priority, void *arg, team_id team)
|
||||
{
|
||||
return create_thread(name, team, function, arg, priority, true);
|
||||
return create_thread(name, team, function, arg, NULL, priority, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1492,7 +1493,7 @@ resume_thread(thread_id id)
|
||||
thread_id
|
||||
spawn_kernel_thread(thread_func function, const char *name, int32 priority, void *arg)
|
||||
{
|
||||
return create_thread(name, team_get_kernel_team()->id, function, arg, priority, true);
|
||||
return create_thread(name, team_get_kernel_team()->id, function, arg, NULL, priority, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1570,7 +1571,7 @@ user_set_thread_priority(thread_id thread, int32 newPriority)
|
||||
|
||||
|
||||
thread_id
|
||||
user_spawn_thread(thread_func entry, const char *userName, int32 priority, void *args)
|
||||
user_spawn_thread(thread_func entry, const char *userName, int32 priority, void *data1, void *data2)
|
||||
{
|
||||
char name[SYS_MAX_OS_NAME_LEN];
|
||||
|
||||
@@ -1579,7 +1580,7 @@ user_spawn_thread(thread_func entry, const char *userName, int32 priority, void
|
||||
|| user_strlcpy(name, userName, SYS_MAX_OS_NAME_LEN) < B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
return create_thread(name, thread_get_current_thread()->team->id, entry, args, priority, false);
|
||||
return create_thread(name, thread_get_current_thread()->team->id, entry, data1, data2, priority, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user