diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h index 733100f7ea..34c89a3a25 100644 --- a/headers/os/kernel/OS.h +++ b/headers/os/kernel/OS.h @@ -97,16 +97,11 @@ extern "C" { * @{ */ -/** - * @typedef team_id - * id of an team (process) - */ /** * @typedef area_id * id of an area */ -typedef int32 team_id; typedef int32 area_id; /** @} */ @@ -205,13 +200,13 @@ int _get_next_port_info(team_id, int32 *, port_info *, size_t); */ typedef struct sem_info { sem_id sem; - proc_id proc; + team_id team; char name[B_OS_NAME_LENGTH]; int32 count; thread_id latest_holder; } sem_info; -sem_id create_sem_etc(int count, const char *name, proc_id owner); +sem_id create_sem_etc(int count, const char *name, team_id owner); sem_id create_sem(int count, const char *name); int delete_sem(sem_id id); int delete_sem_etc(sem_id id, int return_code); @@ -221,8 +216,8 @@ int release_sem(sem_id id); int release_sem_etc(sem_id id, int count, int flags); int get_sem_count(sem_id id, int32* thread_count); int _get_sem_info(sem_id id, struct sem_info *info, size_t); -int _get_next_sem_info(proc_id proc, uint32 *cookie, struct sem_info *info, size_t); -int set_sem_owner(sem_id id, proc_id proc); +int _get_next_sem_info(team_id team, uint32 *cookie, struct sem_info *info, size_t); +int set_sem_owner(sem_id id, team_id team); #define get_sem_info(sem, info) \ _get_sem_info((sem), (info), sizeof(*(info))) @@ -289,7 +284,7 @@ typedef enum { /** information on a thread * @note the thread can be in any state */ -typedef struct { +typedef struct { thread_id thread; team_id team; char name[B_OS_NAME_LENGTH]; @@ -302,6 +297,20 @@ typedef struct { void *stack_end; } thread_info; +/** information on a team */ +typedef struct { + team_id team; + int32 thread_count; + int32 image_count; + int32 area_count; + thread_id debugger_nub_thread; + port_id debugger_nub_port; + int32 argc; + char args[64]; + uid_t uid; + gid_t gid; +} team_info; + /** * gives information on user and kernel time for a thread */ diff --git a/headers/os/kernel/syscalls.h b/headers/os/kernel/syscalls.h index 611dc87ea3..0e117dc737 100755 --- a/headers/os/kernel/syscalls.h +++ b/headers/os/kernel/syscalls.h @@ -51,33 +51,33 @@ bigtime_t sys_system_time(); int sys_snooze(bigtime_t time); /* sem functions */ -sem_id kern_create_sem(int count, const char *name); -int kern_delete_sem(sem_id id); -int kern_acquire_sem(sem_id id); -int kern_acquire_sem_etc(sem_id id, int count, int flags, bigtime_t timeout); -int kern_release_sem(sem_id id); -int kern_release_sem_etc(sem_id id, int count, int flags); +sem_id sys_create_sem(int count, const char *name); +int sys_delete_sem(sem_id id); +int sys_acquire_sem(sem_id id); +int sys_acquire_sem_etc(sem_id id, int count, int flags, bigtime_t timeout); +int sys_release_sem(sem_id id); +int sys_release_sem_etc(sem_id id, int count, int flags); int sys_sem_get_count(sem_id id, int32* thread_count); -int kern_get_sem_info(sem_id, struct sem_info *, size_t); -int kern_get_next_sem_info(proc_id, uint32 *, struct sem_info *, size_t); -int sys_set_sem_owner(sem_id id, proc_id proc); +int sys_get_sem_info(sem_id, struct sem_info *, size_t); +int sys_get_next_sem_info(team_id, uint32 *, struct sem_info *, size_t); +int sys_set_sem_owner(sem_id id, team_id proc); -int sys_proc_get_table(struct proc_info *pi, size_t len); +//int sys_team_get_table(struct proc_info *pi, size_t len); void sys_exit(int retcode); -proc_id sys_proc_create_proc(const char *path, const char *name, char **args, int argc, char **envp, int envc, int priority); +team_id sys_create_team(const char *path, const char *name, char **args, int argc, char **envp, int envc, int priority); -thread_id kern_spawn_thread(int (*func)(void*), const char *, int, void *); -thread_id kern_get_current_thread_id(void); -int kern_suspend_thread(thread_id tid); -int kern_resume_thread(thread_id tid); -int kern_kill_thread(thread_id tid); +thread_id sys_spawn_thread(int (*func)(void*), const char *, int, void *); +thread_id sys_get_current_thread_id(void); +int sys_suspend_thread(thread_id tid); +int sys_resume_thread(thread_id tid); +int sys_kill_thread(thread_id tid); -int sys_thread_wait_on_thread(thread_id tid, int *retcode); -int sys_proc_kill_proc(proc_id pid); +int sys_wait_on_thread(thread_id tid, int *retcode); +int sys_kill_team(team_id tid); -proc_id sys_get_current_proc_id(); -int sys_proc_wait_on_proc(proc_id pid, int *retcode); +team_id sys_get_current_team_id(); +int sys_wait_on_team(team_id tid, int *retcode); region_id sys_vm_create_anonymous_region(const char *name, void **address, int addr_type, addr size, int wiring, int lock); @@ -94,13 +94,13 @@ int sys_port_close(port_id id); int sys_port_delete(port_id id); port_id sys_port_find(const char *port_name); int sys_port_get_info(port_id id, struct port_info *info); -int sys_port_get_next_port_info(proc_id proc, uint32 *cookie, struct port_info *info); +int sys_port_get_next_port_info(team_id team, uint32 *cookie, struct port_info *info); ssize_t sys_port_buffer_size(port_id port); ssize_t sys_port_buffer_size_etc(port_id port, uint32 flags, bigtime_t timeout); int32 sys_port_count(port_id port); ssize_t sys_port_read(port_id port, int32 *msg_code, void *msg_buffer, size_t buffer_size); ssize_t sys_port_read_etc(port_id port, int32 *msg_code, void *msg_buffer, size_t buffer_size, uint32 flags, bigtime_t timeout); -int sys_port_set_owner(port_id port, team_id proc); +int sys_port_set_owner(port_id port, team_id team); int sys_port_write(port_id port, int32 msg_code, const void *msg_buffer, size_t buffer_size); int sys_port_write_etc(port_id port, int32 msg_code, const void *msg_buffer, size_t buffer_size, uint32 flags, bigtime_t timeout); @@ -123,7 +123,7 @@ area_id sys_find_region_by_name(const char *); /* This is a real BSD'ism :) Basically it returns the size of the * descriptor table for the current process as an integer. */ -int kern_getdtablesize(void); +int sys_getdtablesize(void); #ifdef __cplusplus } diff --git a/headers/os/kernel/thread_types.h b/headers/os/kernel/thread_types.h index 1dfc7cb629..369d7bd413 100644 --- a/headers/os/kernel/thread_types.h +++ b/headers/os/kernel/thread_types.h @@ -56,9 +56,9 @@ enum { }; enum { - PROC_STATE_NORMAL, // normal state - PROC_STATE_BIRTH, // being contructed - PROC_STATE_DEATH // being killed + TEAM_STATE_NORMAL, // normal state + TEAM_STATE_BIRTH, // being contructed + TEAM_STATE_DEATH // being killed }; #define SIG_NONE 0 @@ -66,16 +66,14 @@ enum { #define SIG_KILL 2 /** - * The proc structure. + * The team structure; equivalent to a common process. * @note This is available only within the kernel. */ -struct proc { - /** Pointer to next proc structure */ - struct proc *next; - /** The proc_id for this process. - * @note This is equivalent to a team_id (???) - */ - proc_id id; +struct team { + /** Pointer to next team structure */ + struct team *next; + /** The team_id for this process. */ + team_id id; /** name of the process * @note The maximum length is current SYS_MAX_OS_NAME_LEN chars. */ @@ -101,12 +99,12 @@ struct proc { addr user_env_base; struct thread *main_thread; struct thread *thread_list; - struct arch_proc arch_info; + struct arch_team arch_info; }; struct thread { struct thread *all_next; - struct thread *proc_next; + struct thread *team_next; struct thread *q_next; thread_id id; char name[SYS_MAX_OS_NAME_LEN]; @@ -125,7 +123,7 @@ struct thread { addr fault_handler; addr entry; void *args; - struct proc *proc; + struct team *team; sem_id return_code_sem; region_id kernel_stack_region_id; addr kernel_stack_base; @@ -145,18 +143,6 @@ struct thread_queue { struct thread *tail; }; -/** - * Process information structure - * @note Seem to be a lot of duplicated fields with main - * proc structure??? - */ -struct proc_info { - proc_id id; - char name[SYS_MAX_OS_NAME_LEN]; - int state; - int num_threads; -}; - #if 1 /** * Test routine for threads. diff --git a/headers/private/kernel/arch/thread.h b/headers/private/kernel/arch/thread.h index 2aae21133c..c3334fc7fc 100644 --- a/headers/private/kernel/arch/thread.h +++ b/headers/private/kernel/arch/thread.h @@ -7,7 +7,7 @@ #include -int arch_proc_init_proc_struct(struct proc *p, bool kernel); +int arch_team_init_team_struct(struct team *t, bool kernel); int arch_thread_init_thread_struct(struct thread *t); void arch_thread_context_switch(struct thread *t_from, struct thread *t_to); int arch_thread_initialize_kthread_stack(struct thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void)); diff --git a/headers/private/kernel/arch/x86/thread_struct.h b/headers/private/kernel/arch/x86/thread_struct.h index 0dd2856d84..57d394a9e5 100755 --- a/headers/private/kernel/arch/x86/thread_struct.h +++ b/headers/private/kernel/arch/x86/thread_struct.h @@ -18,7 +18,7 @@ struct arch_thread { uint8 fpu_state[512]; }; -struct arch_proc { +struct arch_team { // nothing here }; diff --git a/headers/private/kernel/elf.h b/headers/private/kernel/elf.h index 2b42002268..98b57b070f 100755 --- a/headers/private/kernel/elf.h +++ b/headers/private/kernel/elf.h @@ -7,7 +7,7 @@ #include -int elf_load_uspace(const char *path, struct proc *p, int flags, addr *entry); +int elf_load_uspace(const char *path, struct team *t, int flags, addr *entry); image_id elf_load_kspace(const char *path, const char *sym_prepend); int elf_unload_kspace( const char *path); addr elf_lookup_symbol(image_id id, const char *symbol); diff --git a/headers/private/kernel/fd.h b/headers/private/kernel/fd.h index 650b85ba86..95f967cde2 100644 --- a/headers/private/kernel/fd.h +++ b/headers/private/kernel/fd.h @@ -79,9 +79,9 @@ static struct io_context *get_current_io_context(bool kernel); static __inline struct io_context *get_current_io_context(bool kernel) { if (kernel) - return proc_get_kernel_proc()->ioctx; + return team_get_kernel_team()->ioctx; - return thread_get_current_thread()->proc->ioctx; + return thread_get_current_thread()->team->ioctx; } #endif /* _FILE_H */ diff --git a/headers/private/kernel/ksyscalls.h b/headers/private/kernel/ksyscalls.h index ef3075b17d..17684ebe8d 100755 --- a/headers/private/kernel/ksyscalls.h +++ b/headers/private/kernel/ksyscalls.h @@ -34,9 +34,9 @@ enum { SYSCALL_SEM_RELEASE_ETC, SYSCALL_GET_CURRENT_THREAD_ID, SYSCALL_EXIT_THREAD, - SYSCALL_PROC_CREATE_PROC, - SYSCALL_THREAD_WAIT_ON_THREAD, - SYSCALL_PROC_WAIT_ON_PROC, + SYSCALL_CREATE_TEAM, + SYSCALL_WAIT_ON_THREAD, + SYSCALL_WAIT_ON_TEAM, SYSCALL_VM_CREATE_ANONYMOUS_REGION, SYSCALL_VM_CLONE_REGION, /* 30 */ SYSCALL_VM_MAP_FILE, @@ -47,8 +47,8 @@ enum { SYSCALL_KILL_THREAD, SYSCALL_SUSPEND_THREAD, SYSCALL_RESUME_THREAD, - SYSCALL_PROC_KILL_PROC, - SYSCALL_GET_CURRENT_PROC_ID, + SYSCALL_KILL_TEAM, + SYSCALL_GET_CURRENT_TEAM_ID, SYSCALL_GETCWD, /* 40 */ SYSCALL_SETCWD, SYSCALL_PORT_CREATE, diff --git a/headers/private/kernel/ktypes.h b/headers/private/kernel/ktypes.h index 4ac8bd221f..86df12b789 100755 --- a/headers/private/kernel/ktypes.h +++ b/headers/private/kernel/ktypes.h @@ -16,7 +16,7 @@ typedef int pid_t; typedef int thread_id; typedef int region_id; typedef int aspace_id; -typedef int proc_id; +typedef int team_id; typedef int sem_id; typedef int port_id; typedef int image_id; diff --git a/headers/private/kernel/port.h b/headers/private/kernel/port.h index b4fc4d4835..515d911206 100755 --- a/headers/private/kernel/port.h +++ b/headers/private/kernel/port.h @@ -12,7 +12,7 @@ #define PORT_FLAG_USE_USER_MEMCPY 0x80000000 int port_init(kernel_args *ka); -int delete_owned_ports(proc_id owner); +int delete_owned_ports(team_id owner); // temp: test void port_test(void); @@ -24,7 +24,7 @@ int user_close_port(port_id id); int user_delete_port(port_id id); port_id user_find_port(const char *port_name); int user_get_port_info(port_id id, struct port_info *info); -int user_get_next_port_info(proc_id proc, +int user_get_next_port_info(team_id team, uint32 *cookie, struct port_info *info); ssize_t user_port_buffer_size_etc(port_id port, @@ -37,7 +37,7 @@ ssize_t user_read_port_etc(port_id port, size_t buffer_size, uint32 flags, bigtime_t timeout); -int user_set_port_owner(port_id port, proc_id proc); +int user_set_port_owner(port_id port, team_id team); int user_write_port_etc(port_id port, int32 msg_code, void *msg_buffer, diff --git a/headers/private/kernel/sem.h b/headers/private/kernel/sem.h index b6628a4588..4c09fd9a29 100755 --- a/headers/private/kernel/sem.h +++ b/headers/private/kernel/sem.h @@ -24,12 +24,12 @@ int user_release_sem(sem_id id); int user_release_sem_etc(sem_id id, int count, int flags); int user_get_sem_count(sem_id id, int32* thread_count); int user_get_sem_info(sem_id, struct sem_info *, size_t); -int user_get_next_sem_info(proc_id, uint32 *, struct sem_info *, size_t); -int user_set_sem_owner(sem_id id, proc_id proc); +int user_get_next_sem_info(team_id, uint32 *, struct sem_info *, size_t); +int user_set_sem_owner(sem_id id, team_id team); int sem_init(kernel_args *ka); -int sem_delete_owned_sems(proc_id owner); +int sem_delete_owned_sems(team_id owner); int sem_interrupt_thread(struct thread *t); /* #endif */ diff --git a/headers/private/kernel/sysctl.h b/headers/private/kernel/sysctl.h index 773de0c322..7615c2c5da 100644 --- a/headers/private/kernel/sysctl.h +++ b/headers/private/kernel/sysctl.h @@ -105,7 +105,7 @@ struct ctlname { #ifdef _KERNEL_MODE typedef int (sysctlfn)(int *, uint, void *, size_t *, void *, size_t); - int kern_sysctl(int *, uint, void *, size_t *, void *, size_t); + int sys_sysctl(int *, uint, void *, size_t *, void *, size_t); int hw_sysctl(int *, uint, void *, size_t *, void *, size_t); int sysctl_int (void *, size_t *, void *, size_t, int *); int sysctl_rdint (void *, size_t *, void *, int); diff --git a/headers/private/kernel/thread.h b/headers/private/kernel/thread.h index f63a5c120f..1628c4c1d1 100755 --- a/headers/private/kernel/thread.h +++ b/headers/private/kernel/thread.h @@ -44,28 +44,28 @@ extern inline thread_id thread_get_current_thread_id(void) { } int thread_wait_on_thread(thread_id id, int *retcode); -thread_id thread_create_user_thread(char *name, proc_id pid, addr entry, void *args); +thread_id thread_create_user_thread(char *name, team_id tid, addr entry, void *args); thread_id thread_create_kernel_thread(const char *name, int (*func)(void *args), void *args); -struct proc *proc_get_kernel_proc(void); -proc_id proc_create_proc(const char *path, const char *name, char **args, int argc, char **envp, int envc, int priority); -int proc_kill_proc(proc_id); -int proc_wait_on_proc(proc_id id, int *retcode); -proc_id proc_get_kernel_proc_id(void); -proc_id proc_get_current_proc_id(void); -char **user_proc_get_arguments(void); -int user_proc_get_arg_count(void); +struct team *team_get_kernel_team(void); +team_id team_create_team(const char *path, const char *name, char **args, int argc, char **envp, int envc, int priority); +int team_kill_team(team_id); +int team_wait_on_team(team_id id, int *retcode); +team_id team_get_kernel_team_id(void); +team_id team_get_current_team_id(void); +char **user_team_get_arguments(void); +int user_team_get_arg_count(void); // used in syscalls.c int user_thread_wait_on_thread(thread_id id, int *uretcode); -proc_id user_proc_create_proc(const char *path, const char *name, char **args, int argc, char **envp, int envc, int priority); -int user_proc_wait_on_proc(proc_id id, int *uretcode); +team_id user_team_create_team(const char *path, const char *name, char **args, int argc, char **envp, int envc, int priority); +int user_team_wait_on_team(team_id id, int *uretcode); -thread_id user_thread_create_user_thread(addr, proc_id, const char*, +thread_id user_thread_create_user_thread(addr, team_id, const char*, int, void *); int user_thread_snooze(bigtime_t time); -int user_proc_get_table(struct proc_info *pi, size_t len); +//int user_proc_get_table(struct proc_info *pi, size_t len); int user_getrlimit(int resource, struct rlimit * rlp); int user_setrlimit(int resource, const struct rlimit * rlp); diff --git a/src/kernel/apps/envtest/main.c b/src/kernel/apps/envtest/main.c index 7ed90d5875..bef05f5e7e 100644 --- a/src/kernel/apps/envtest/main.c +++ b/src/kernel/apps/envtest/main.c @@ -7,7 +7,7 @@ int main(int argc, char **argv) { int i, rc; - proc_id pid; + team_id pid; char temp[16]; char *var; @@ -47,8 +47,8 @@ int main(int argc, char **argv) if (val > 0) { printf("Spawning test (%d left)\n", val); sprintf(buffer, "%d", val); - pid = sys_proc_create_proc(_argv[0], _argv[0], _argv, 2, NULL, 0, 5); - sys_proc_wait_on_proc(pid, &rc); + pid = sys_create_team(_argv[0], _argv[0], _argv, 2, NULL, 0, 5); + sys_wait_on_team(pid, &rc); } } return 0; diff --git a/src/kernel/apps/fibo_main.c b/src/kernel/apps/fibo_main.c index 11a60d6724..a91b557a20 100644 --- a/src/kernel/apps/fibo_main.c +++ b/src/kernel/apps/fibo_main.c @@ -43,20 +43,20 @@ main(int argc, char *argv[]) if(num < 2) { result= 1; } else { - proc_id pid; + team_id pid; int retcode; char buffer[64]; char *aaargv[]= { "/boot/bin/fibo", "-s", buffer, NULL }; int aaargc= 3; sprintf(buffer, "%d", num-1); - pid= sys_proc_create_proc(aaargv[0], aaargv[0], aaargv, aaargc, NULL, 0, 5); - sys_proc_wait_on_proc(pid, &retcode); + pid= sys_create_team(aaargv[0], aaargv[0], aaargv, aaargc, NULL, 0, 5); + sys_wait_on_team(pid, &retcode); result= retcode; sprintf(buffer, "%d", num-2); - pid= sys_proc_create_proc(aaargv[0], aaargv[0], aaargv, aaargc, NULL, 0, 5); - sys_proc_wait_on_proc(pid, &retcode); + pid= sys_create_team(aaargv[0], aaargv[0], aaargv, aaargc, NULL, 0, 5); + sys_wait_on_team(pid, &retcode); result+= retcode; } diff --git a/src/kernel/apps/init.c b/src/kernel/apps/init.c index 19dd08407f..70071a11d9 100644 --- a/src/kernel/apps/init.c +++ b/src/kernel/apps/init.c @@ -31,26 +31,26 @@ int main() printf("Welcome to OpenBeOS!\n"); if(1) { - proc_id pid; + team_id pid; - pid = sys_proc_create_proc("/boot/bin/fortune", "/boot/bin/fortune", NULL, 0, NULL, 0, 5); + pid = sys_create_team("/boot/bin/fortune", "/boot/bin/fortune", NULL, 0, NULL, 0, 5); if (pid >= 0) { int retcode; - sys_proc_wait_on_proc(pid, &retcode); + sys_wait_on_team(pid, &retcode); } else { - printf("Failed to create a proc for fortune.\n"); + printf("Failed to create a team for fortune.\n"); } } while(1) { - proc_id pid; + team_id pid; - pid = sys_proc_create_proc("/boot/bin/shell", "/boot/bin/shell", NULL, 0, NULL, 0, 5); + pid = sys_create_team("/boot/bin/shell", "/boot/bin/shell", NULL, 0, NULL, 0, 5); if(pid >= 0) { int retcode; printf("init: spawned shell, pid 0x%x\n", pid); - sys_proc_wait_on_proc(pid, &retcode); + sys_wait_on_team(pid, &retcode); printf("init: shell exited with return code %d\n", retcode); } else { printf("Failed to start a shell :(\n"); diff --git a/src/kernel/apps/ps/main.c b/src/kernel/apps/ps/main.c index 963577284b..3927686bcc 100644 --- a/src/kernel/apps/ps/main.c +++ b/src/kernel/apps/ps/main.c @@ -14,6 +14,7 @@ #include #include +#if 0 #define MAX_PROCESSES 1024 @@ -72,3 +73,11 @@ main(int argc, char ** argv) return 0; } +#else + +int main(int argc, char **argv) +{ + return 0; +} + +#endif diff --git a/src/kernel/apps/rld/rldheap.c b/src/kernel/apps/rld/rldheap.c index f9b85cabc9..1d182f4175 100644 --- a/src/kernel/apps/rld/rldheap.c +++ b/src/kernel/apps/rld/rldheap.c @@ -35,7 +35,7 @@ void rldheap_init(void) { rld_region= sys_vm_create_anonymous_region( - (char*)names[sys_get_current_proc_id()%(sizeof(names)/sizeof(names[0]))], + (char*)names[sys_get_current_team_id()%(sizeof(names)/sizeof(names[0]))], (void**)&rld_base, REGION_ADDR_ANY_ADDRESS, RLD_SCRATCH_SIZE, diff --git a/src/kernel/apps/shell/commands.c b/src/kernel/apps/shell/commands.c index beec283fd3..6e04c94e97 100644 --- a/src/kernel/apps/shell/commands.c +++ b/src/kernel/apps/shell/commands.c @@ -30,7 +30,7 @@ int cmd_exec(int argc, char *argv[]) int cmd_create_proc(int argc,char *argv[]) { bool must_wait=true; - proc_id pid; + team_id pid; int arg_len; char *tmp; @@ -65,12 +65,12 @@ int cmd_create_proc(int argc,char *argv[]) } } - pid = sys_proc_create_proc(filename,filename, argv, argc, NULL, 0, 5); + pid = sys_create_team(filename,filename, argv, argc, NULL, 0, 5); if(pid >= 0) { int retcode; if(must_wait) { - sys_proc_wait_on_proc(pid, &retcode); + sys_wait_on_team(pid, &retcode); } } else { printf("Error: cannot execute '%s'\n", filename); diff --git a/src/kernel/apps/shell/file_utils.c b/src/kernel/apps/shell/file_utils.c index 803e7dad47..6f22f6d601 100644 --- a/src/kernel/apps/shell/file_utils.c +++ b/src/kernel/apps/shell/file_utils.c @@ -71,11 +71,11 @@ int exec_file(int argc,char *argv[],int *retcode) if( !find_file_in_path(argv[0],filename,SCAN_SIZE)) return SHE_FILE_NOT_FOUND; - pid = sys_proc_create_proc(filename,filename, argv, argc, NULL, 0, 5); + pid = sys_create_team(filename,filename, argv, argc, NULL, 0, 5); if(pid < 0) return SHE_CANT_EXECUTE; - sys_proc_wait_on_proc(pid, retcode); + sys_wait_on_team(pid, retcode); return SHE_NO_ERROR; } diff --git a/src/kernel/apps/testapp/main.c b/src/kernel/apps/testapp/main.c index 3ca49a2c73..d27c9d145c 100644 --- a/src/kernel/apps/testapp/main.c +++ b/src/kernel/apps/testapp/main.c @@ -155,7 +155,7 @@ int main(int argc, char **argv) } sys_snooze(5000000); - sys_proc_kill_proc(sys_get_current_proc_id()); + sys_kill_team(sys_get_current_team_id()); /* sys_snooze(3000000); for(i=0; i<10; i++) { @@ -169,7 +169,7 @@ int main(int argc, char **argv) #if 0 { for(;;) - sys_proc_create_proc("/boot/bin/true", "true", 32); + sys_create_team("/boot/bin/true", "true", 32); } #endif #if 0 @@ -325,32 +325,32 @@ int main(int argc, char **argv) printf("%d\n", *((int *)ptr + 3)); } #endif -#if 0 +#if 1 { int i; -// printf("spawning %d copies of true\n", 10000); + printf("spawning %d copies of true\n", 100); - for(i=0; ; i++) { - proc_id id; + for(i=0; i<100; i++) { + team_id id; bigtime_t t; printf("%d...", i); t = sys_system_time(); - id = sys_proc_create_proc("/boot/bin/true", "true", NULL, 0, 20); + id = sys_create_team("/boot/bin/true", "true", NULL, 0, NULL, 0, 20); if(id <= 0x2) { - printf("new proc returned 0x%x!\n", id); + printf("new team returned 0x%x!\n", id); return -1; } - sys_proc_wait_on_proc(id, NULL); + sys_wait_on_team(id, NULL); printf("done (%Ld usecs)\n", sys_system_time() - t); } } #endif -#if 0 +#if 1 { int i; @@ -359,9 +359,9 @@ int main(int argc, char **argv) // resume_thread(spawn_thread("cpu eater 1", &cpu_eater_thread, 0)); // resume_thread(spawn_thread(&cpu_eater_thread, "cpu eater 2", &cpu_eater_thread, 0)); - printf("spawning %d threads\n", 10000); + printf("spawning %d threads\n", 100); - for(i=0; i<10000; i++) { + for(i=0; i<100; i++) { thread_id id; bigtime_t t; @@ -373,7 +373,7 @@ int main(int argc, char **argv) if (id > 0) resume_thread(id); - sys_thread_wait_on_thread(id, NULL); + sys_wait_on_thread(id, NULL); printf("done (%Ld usecs)\n", sys_system_time() - t); } @@ -466,7 +466,7 @@ static void port_test(void) sys_port_write(test_p1, 3, &testdata, sizeof(testdata)); printf("porttest: waiting on spawned thread\n"); - sys_thread_wait_on_thread(t, NULL); + sys_wait_on_thread(t, NULL); printf("porttest: close p1\n"); sys_port_close(test_p2); diff --git a/src/kernel/apps/tests/thread_test.c b/src/kernel/apps/tests/thread_test.c index 1a7586a136..16e06d8406 100644 --- a/src/kernel/apps/tests/thread_test.c +++ b/src/kernel/apps/tests/thread_test.c @@ -56,7 +56,7 @@ int main(int argc, char **argv) } } - sys_thread_wait_on_thread(t[THREADS - 1], NULL); + sys_wait_on_thread(t[THREADS - 1], NULL); printf("Test value = %d vs expected of %d\n", current_val, expected); diff --git a/src/kernel/core/arch/x86/arch_thread.c b/src/kernel/core/arch/x86/arch_thread.c index de5e090458..7ce0e40f4e 100755 --- a/src/kernel/core/arch/x86/arch_thread.c +++ b/src/kernel/core/arch/x86/arch_thread.c @@ -12,7 +12,7 @@ #include #include -int arch_proc_init_proc_struct(struct proc *p, bool kernel) +int arch_team_init_team_struct(struct team *p, bool kernel) { return 0; } @@ -87,7 +87,7 @@ void arch_thread_context_switch(struct thread *t_from, struct thread *t_to) dprintf("arch_thread_context_switch: cpu %d 0x%x -> 0x%x, aspace 0x%x -> 0x%x, old stack = 0x%x:0x%x, stack = 0x%x:0x%x\n", smp_get_current_cpu(), t_from->id, t_to->id, - t_from->proc->aspace, t_to->proc->aspace, + t_from->team->aspace, t_to->team->aspace, t_from->arch_info.current_stack.ss, t_from->arch_info.current_stack.esp, t_to->arch_info.current_stack.ss, t_to->arch_info.current_stack.esp); #endif @@ -103,23 +103,23 @@ void arch_thread_context_switch(struct thread *t_from, struct thread *t_to) } #endif - if(t_from->proc->_aspace_id >= 0 && t_to->proc->_aspace_id >= 0) { + if(t_from->team->_aspace_id >= 0 && t_to->team->_aspace_id >= 0) { // they are both uspace threads - if(t_from->proc->_aspace_id == t_to->proc->_aspace_id) { + if(t_from->team->_aspace_id == t_to->team->_aspace_id) { // dont change the pgdir, same address space new_pgdir = NULL; } else { // switching to a new address space - new_pgdir = vm_translation_map_get_pgdir(&t_to->proc->aspace->translation_map); + new_pgdir = vm_translation_map_get_pgdir(&t_to->team->aspace->translation_map); } - } else if(t_from->proc->_aspace_id < 0 && t_to->proc->_aspace_id < 0) { + } else if(t_from->team->_aspace_id < 0 && t_to->team->_aspace_id < 0) { // they must both be kspace threads new_pgdir = NULL; - } else if(t_to->proc->_aspace_id < 0) { + } else if(t_to->team->_aspace_id < 0) { // the one we're switching to is kspace - new_pgdir = vm_translation_map_get_pgdir(&t_to->proc->kaspace->translation_map); + new_pgdir = vm_translation_map_get_pgdir(&t_to->team->kaspace->translation_map); } else { - new_pgdir = vm_translation_map_get_pgdir(&t_to->proc->aspace->translation_map); + new_pgdir = vm_translation_map_get_pgdir(&t_to->team->aspace->translation_map); } #if 0 dprintf("new_pgdir is 0x%x\n", new_pgdir); diff --git a/src/kernel/core/elf.c b/src/kernel/core/elf.c index 7d62b37d1d..a5a86d472e 100644 --- a/src/kernel/core/elf.c +++ b/src/kernel/core/elf.c @@ -617,7 +617,7 @@ verify_eheader(struct Elf32_Ehdr *eheader) int -elf_load_uspace(const char *path, struct proc *p, int flags, addr *entry) +elf_load_uspace(const char *path, struct team *p, int flags, addr *entry) { struct Elf32_Ehdr eheader; struct Elf32_Phdr *pheaders = NULL; @@ -626,7 +626,7 @@ elf_load_uspace(const char *path, struct proc *p, int flags, addr *entry) int i; ssize_t len; - dprintf("elf_load: entry path '%s', proc %p\n", path, p); + dprintf("elf_load: entry path '%s', team %p\n", path, p); fd = sys_open(path, 0); if(fd < 0) diff --git a/src/kernel/core/main.c b/src/kernel/core/main.c index bfe693b4ff..2191e89093 100644 --- a/src/kernel/core/main.c +++ b/src/kernel/core/main.c @@ -147,8 +147,8 @@ static int main2(void *unused) #endif // start the init process { - proc_id pid; - pid = proc_create_proc("/boot/bin/init", "init", NULL, 0, NULL, 0, 5); + team_id pid; + pid = team_create_team("/boot/bin/init", "init", NULL, 0, NULL, 0, 5); if(pid < 0) kprintf("error starting 'init' error = %d \n",pid); } diff --git a/src/kernel/core/port.c b/src/kernel/core/port.c index 12d5d9df09..e1e6df6022 100644 --- a/src/kernel/core/port.c +++ b/src/kernel/core/port.c @@ -25,7 +25,7 @@ struct port_msg { struct port_entry { port_id id; - proc_id owner; + team_id owner; int32 capacity; int lock; char *name; @@ -163,7 +163,7 @@ create_port(int32 queue_length, const char *name) port_id retval; char *temp_name; void *q; - proc_id owner; + team_id owner; if(ports_active == false) return B_BAD_PORT_ID; @@ -213,7 +213,7 @@ create_port(int32 queue_length, const char *name) kfree(q); return sem_w; } - owner = proc_get_current_proc_id(); + owner = team_get_current_team_id(); state = disable_interrupts(); GRAB_PORT_LIST_LOCK(); @@ -431,7 +431,7 @@ _get_port_info(port_id id, port_info *info, size_t size) } int -_get_next_port_info(team_id proc, int32 *cookie, struct port_info *info, +_get_next_port_info(team_id team, int32 *cookie, struct port_info *info, size_t size) { int state; @@ -460,7 +460,7 @@ _get_next_port_info(team_id proc, int32 *cookie, struct port_info *info, while (slot < MAX_PORTS) { GRAB_PORT_LOCK(ports[slot]); if (ports[slot].id != -1) - if (ports[slot].owner == proc) { + if (ports[slot].owner == team) { // found one! // copy the info info->port = ports[slot].id; @@ -727,7 +727,7 @@ read_port_etc(port_id id, } int -set_port_owner(port_id id, proc_id proc) +set_port_owner(port_id id, team_id team) { int slot; int state; @@ -749,8 +749,8 @@ set_port_owner(port_id id, proc_id proc) return B_BAD_PORT_ID; } - // transfer ownership to other process - ports[slot].owner = proc; + // transfer ownership to other team + ports[slot].owner = team; // unlock port RELEASE_PORT_LOCK(ports[slot]); @@ -896,8 +896,8 @@ write_port_etc(port_id id, } /* this function cycles through the ports table, deleting all the ports that are owned by - the passed proc_id */ -int delete_owned_ports(proc_id owner) + the passed team_id */ +int delete_owned_ports(team_id owner) { int state; int i; @@ -1099,7 +1099,7 @@ int user_get_port_info(port_id id, struct port_info *uinfo) return res; } -int user_get_next_port_info(proc_id uproc, +int user_get_next_port_info(team_id uteam, uint32 *ucookie, struct port_info *uinfo) { @@ -1122,7 +1122,7 @@ int user_get_next_port_info(proc_id uproc, if(rc < 0) return rc; - res = get_next_port_info(uproc, &cookie, &info); + res = get_next_port_info(uteam, &cookie, &info); // copy to userspace rc = user_memcpy(ucookie, &info, sizeof(uint32)); if(rc < 0) @@ -1170,9 +1170,9 @@ ssize_t user_read_port_etc(port_id uport, int32 *umsg_code, void *umsg_buffer, return res; } -int user_set_port_owner(port_id port, proc_id proc) +int user_set_port_owner(port_id port, team_id team) { - return set_port_owner(port, proc); + return set_port_owner(port, team); } int user_write_port_etc(port_id uport, int32 umsg_code, void *umsg_buffer, diff --git a/src/kernel/core/sem.c b/src/kernel/core/sem.c index 827b6c795c..ffb51a95ec 100644 --- a/src/kernel/core/sem.c +++ b/src/kernel/core/sem.c @@ -28,7 +28,7 @@ struct sem_entry { struct thread_queue q; char *name; int lock; - proc_id owner; // if set to -1, means owned by a port + team_id owner; // if set to -1, means owned by a port }; #define MAX_SEMS 4096 @@ -142,7 +142,7 @@ int sem_init(kernel_args *ka) return 0; } -sem_id create_sem_etc(int count, const char *name, proc_id owner) +sem_id create_sem_etc(int count, const char *name, team_id owner) { int i; int state; @@ -208,7 +208,7 @@ out: sem_id create_sem(int count, const char *name) { - return create_sem_etc(count, name, proc_get_kernel_proc_id()); + return create_sem_etc(count, name, team_get_kernel_team_id()); } int delete_sem(sem_id id) @@ -581,7 +581,7 @@ int _get_sem_info(sem_id id, struct sem_info *info, size_t sz) } info->sem = sems[slot].id; - info->proc = sems[slot].owner; + info->team = sems[slot].owner; strncpy(info->name, sems[slot].name, SYS_MAX_OS_NAME_LEN-1); info->count = sems[slot].count; info->latest_holder = sems[slot].q.head->id; // XXX not sure if this is correct @@ -592,7 +592,7 @@ int _get_sem_info(sem_id id, struct sem_info *info, size_t sz) return B_NO_ERROR; } -int _get_next_sem_info(proc_id proc, uint32 *cookie, struct sem_info *info, size_t sz) +int _get_next_sem_info(team_id team, uint32 *cookie, struct sem_info *info, size_t sz) { int state; int slot; @@ -602,7 +602,7 @@ int _get_next_sem_info(proc_id proc, uint32 *cookie, struct sem_info *info, size if (cookie == NULL) return EINVAL; /* prevents sems[].owner == -1 >= means owned by a port */ - if (proc < 0) + if (team < 0) return EINVAL; if (*cookie == NULL) { @@ -622,10 +622,10 @@ int _get_next_sem_info(proc_id proc, uint32 *cookie, struct sem_info *info, size while (slot < MAX_SEMS) { GRAB_SEM_LOCK(sems[slot]); if (sems[slot].id != -1) - if (sems[slot].owner == proc) { + if (sems[slot].owner == team) { // found one! info->sem = sems[slot].id; - info->proc = sems[slot].owner; + info->team = sems[slot].owner; strncpy(info->name, sems[slot].name, SYS_MAX_OS_NAME_LEN-1); info->count = sems[slot].count; info->latest_holder = sems[slot].q.head->id; // XXX not sure if this is the latest holder, or the next holder... @@ -646,7 +646,7 @@ int _get_next_sem_info(proc_id proc, uint32 *cookie, struct sem_info *info, size return B_NO_ERROR; } -int set_sem_owner(sem_id id, proc_id proc) +int set_sem_owner(sem_id id, team_id team) { int state; int slot; @@ -655,12 +655,12 @@ int set_sem_owner(sem_id id, proc_id proc) return B_NO_MORE_SEMS; if (id < 0) return B_BAD_SEM_ID; - if (proc < 0) + if (team < 0) return EINVAL; - // XXX: todo check if proc exists -// if (proc_get_proc_struct(proc) == NULL) -// return B_BAD_SEM_ID; // proc_id doesn't exist right now + // XXX: todo check if team exists +// if (team_get_team_struct(team) == NULL) +// return B_BAD_SEM_ID; // team_id doesn't exist right now slot = id % MAX_SEMS; @@ -674,7 +674,7 @@ int set_sem_owner(sem_id id, proc_id proc) return B_BAD_SEM_ID; } - sems[slot].owner = proc; + sems[slot].owner = team; RELEASE_SEM_LOCK(sems[slot]); restore_interrupts(state); @@ -749,8 +749,8 @@ static int remove_thread_from_sem(struct thread *t, struct sem_entry *sem, struc } /* this function cycles through the sem table, deleting all the sems that are owned by - the passed proc_id */ -int sem_delete_owned_sems(proc_id owner) + the passed team_id */ +int sem_delete_owned_sems(team_id owner) { int state; int i; @@ -797,10 +797,10 @@ sem_id user_create_sem(int count, const char *uname) return rc; name[SYS_MAX_OS_NAME_LEN-1] = 0; - return create_sem_etc(count, name, proc_get_current_proc_id()); + return create_sem_etc(count, name, team_get_current_team_id()); } else { - return create_sem_etc(count, NULL, proc_get_current_proc_id()); + return create_sem_etc(count, NULL, team_get_current_team_id()); } } @@ -862,7 +862,7 @@ int user_get_sem_info(sem_id uid, struct sem_info *uinfo, size_t sz) return rc; } -int user_get_next_sem_info(proc_id uproc, uint32 *ucookie, struct sem_info *uinfo, size_t sz) +int user_get_next_sem_info(team_id uteam, uint32 *ucookie, struct sem_info *uinfo, size_t sz) { struct sem_info info; uint32 cookie; @@ -874,7 +874,7 @@ int user_get_next_sem_info(proc_id uproc, uint32 *ucookie, struct sem_info *uinf rc2 = user_memcpy(&cookie, ucookie, sizeof(uint32)); if (rc2 < 0) return rc2; - rc = _get_next_sem_info(uproc, &cookie, &info, sz); + rc = _get_next_sem_info(uteam, &cookie, &info, sz); rc2 = user_memcpy(uinfo, &info, sz); if (rc2 < 0) return rc2; @@ -884,7 +884,7 @@ int user_get_next_sem_info(proc_id uproc, uint32 *ucookie, struct sem_info *uinf return rc; } -int user_set_sem_owner(sem_id uid, proc_id uproc) +int user_set_sem_owner(sem_id uid, team_id uteam) { - return set_sem_owner(uid, uproc); + return set_sem_owner(uid, uteam); } diff --git a/src/kernel/core/syscalls.c b/src/kernel/core/syscalls.c index 78530225e3..1abb0ae2db 100644 --- a/src/kernel/core/syscalls.c +++ b/src/kernel/core/syscalls.c @@ -157,14 +157,14 @@ int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_re thread_exit((int)arg0); *call_ret = 0; break; - case SYSCALL_PROC_CREATE_PROC: - *call_ret = user_proc_create_proc((const char *)arg0, (const char *)arg1, (char **)arg2, (int)arg3, (char **)arg4, (int)arg5, (int)arg6); + case SYSCALL_CREATE_TEAM: + *call_ret = user_team_create_team((const char *)arg0, (const char *)arg1, (char **)arg2, (int)arg3, (char **)arg4, (int)arg5, (int)arg6); break; - case SYSCALL_THREAD_WAIT_ON_THREAD: + case SYSCALL_WAIT_ON_THREAD: *call_ret = user_thread_wait_on_thread((thread_id)arg0, (int *)arg1); break; - case SYSCALL_PROC_WAIT_ON_PROC: - *call_ret = user_proc_wait_on_proc((proc_id)arg0, (int *)arg1); + case SYSCALL_WAIT_ON_TEAM: + *call_ret = user_team_wait_on_team((team_id)arg0, (int *)arg1); break; case SYSCALL_VM_CREATE_ANONYMOUS_REGION: *call_ret = user_vm_create_anonymous_region( @@ -192,7 +192,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_thread_create_user_thread((addr)arg0, thread_get_current_thread()->proc->id, + *call_ret = user_thread_create_user_thread((addr)arg0, thread_get_current_thread()->team->id, (const char*)arg1, (int)arg2, (void *)arg3); break; case SYSCALL_KILL_THREAD: @@ -204,11 +204,11 @@ int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_re case SYSCALL_RESUME_THREAD: *call_ret = thread_resume_thread((thread_id)arg0); break; - case SYSCALL_PROC_KILL_PROC: - *call_ret = proc_kill_proc((proc_id)arg0); + case SYSCALL_KILL_TEAM: + *call_ret = team_kill_team((team_id)arg0); break; - case SYSCALL_GET_CURRENT_PROC_ID: - *call_ret = proc_get_current_proc_id(); + case SYSCALL_GET_CURRENT_TEAM_ID: + *call_ret = team_get_current_team_id(); break; case SYSCALL_GETCWD: *call_ret = user_getcwd((char*)arg0, (size_t)arg1); @@ -250,7 +250,7 @@ int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_re *call_ret = user_read_port_etc((port_id)arg0, (int32*)arg1, (void*)arg2, (size_t)arg3, (uint32)arg4 | B_CAN_INTERRUPT, (bigtime_t)INT32TOINT64(arg5, arg6)); break; case SYSCALL_PORT_SET_OWNER: - *call_ret = user_set_port_owner((port_id)arg0, (proc_id)arg1); + *call_ret = user_set_port_owner((port_id)arg0, (team_id)arg1); break; case SYSCALL_PORT_WRITE: *call_ret = user_write_port_etc((port_id)arg0, (int32)arg1, (void *)arg2, (size_t)arg3, B_CAN_INTERRUPT, 0); @@ -265,11 +265,11 @@ int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_re *call_ret = user_get_sem_info((sem_id)arg0, (struct sem_info *)arg1, (size_t)arg2); break; case SYSCALL_SEM_GET_NEXT_SEM_INFO: - *call_ret = user_get_next_sem_info((proc_id)arg0, (uint32 *)arg1, (struct sem_info *)arg2, + *call_ret = user_get_next_sem_info((team_id)arg0, (uint32 *)arg1, (struct sem_info *)arg2, (size_t)arg3); break; case SYSCALL_SEM_SET_SEM_OWNER: - *call_ret = user_set_sem_owner((sem_id)arg0, (proc_id)arg1); + *call_ret = user_set_sem_owner((sem_id)arg0, (team_id)arg1); break; case SYSCALL_FDDUP: *call_ret = user_dup(arg0); @@ -278,7 +278,7 @@ int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_re *call_ret = user_dup2(arg0, arg1); break; case SYSCALL_GET_PROC_TABLE: - *call_ret = user_proc_get_table((struct proc_info *)arg0, (size_t)arg1); + *call_ret = user_team_get_table((struct team_info *)arg0, (size_t)arg1); break; case SYSCALL_GETRLIMIT: *call_ret = user_getrlimit((int)arg0, (struct rlimit *)arg1); diff --git a/src/kernel/core/sysctl.c b/src/kernel/core/sysctl.c index 9eec39d9c6..61d4282ed4 100644 --- a/src/kernel/core/sysctl.c +++ b/src/kernel/core/sysctl.c @@ -46,7 +46,7 @@ int sysctl(int *name, uint namelen, void *oldp, size_t *oldlenp, switch (name[0]) { case CTL_KERN: - fn = kern_sysctl; + fn = sys_sysctl; break; case CTL_HW: fn = hw_sysctl; @@ -61,7 +61,7 @@ int sysctl(int *name, uint namelen, void *oldp, size_t *oldlenp, } -int kern_sysctl(int *name, uint namelen, void *oldp, size_t *oldlenp, +int sys_sysctl(int *name, uint namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { int error = 0; diff --git a/src/kernel/core/thread.c b/src/kernel/core/thread.c index d9dd6f04be..f8530e0eeb 100644 --- a/src/kernel/core/thread.c +++ b/src/kernel/core/thread.c @@ -1,4 +1,4 @@ -/* Threading and process information */ +/* Threading and team information */ /* ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -36,15 +36,15 @@ #include -struct proc_key { - proc_id id; +struct team_key { + team_id id; }; struct thread_key { thread_id id; }; -struct proc_arg { +struct team_arg { char *path; char **args; char **envp; @@ -52,22 +52,22 @@ struct proc_arg { unsigned int envc; }; -static struct proc *create_proc_struct(const char *name, bool kernel); -static int proc_struct_compare(void *_p, const void *_key); -static unsigned int proc_struct_hash(void *_p, const void *_key, unsigned int range); +static struct team *create_team_struct(const char *name, bool kernel); +static int team_struct_compare(void *_p, const void *_key); +static unsigned int team_struct_hash(void *_p, const void *_key, unsigned int range); // global spinlock_t thread_spinlock = 0; -// proc list -static void *proc_hash = NULL; -static struct proc *kernel_proc = NULL; -static proc_id next_proc_id = 0; -static spinlock_t proc_spinlock = 0; - // NOTE: PROC lock can be held over a THREAD lock acquisition, +// team list +static void *team_hash = NULL; +static struct team *kernel_team = NULL; +static team_id next_team_id = 0; +static spinlock_t team_spinlock = 0; + // NOTE: TEAM lock can be held over a THREAD lock acquisition, // but not the other way (to avoid deadlock) -#define GRAB_PROC_LOCK() acquire_spinlock(&proc_spinlock) -#define RELEASE_PROC_LOCK() release_spinlock(&proc_spinlock) +#define GRAB_TEAM_LOCK() acquire_spinlock(&team_spinlock) +#define RELEASE_TEAM_LOCK() release_spinlock(&team_spinlock) // thread list static struct thread *idle_threads[MAX_BOOT_CPUS]; @@ -95,9 +95,9 @@ static int _rand(void); static void thread_entry(void); static struct thread *thread_get_thread_struct_locked(thread_id id); /* XXX - not currently used, so commented out -static struct proc *proc_get_proc_struct(proc_id id); +static struct team *team_get_team_struct(team_id id); */ -static struct proc *proc_get_proc_struct_locked(proc_id id); +static struct team *team_get_team_struct_locked(team_id id); static void thread_kthread_exit(void); static void deliver_signal(struct thread *t, int signal); @@ -176,28 +176,28 @@ struct thread *thread_dequeue_run_q(int priority) return thread_dequeue(&run_q[priority]); } -static void insert_thread_into_proc(struct proc *p, struct thread *t) +static void insert_thread_into_team(struct team *p, struct thread *t) { - t->proc_next = p->thread_list; + t->team_next = p->thread_list; p->thread_list = t; p->num_threads++; if(p->num_threads == 1) { // this was the first thread p->main_thread = t; } - t->proc = p; + t->team = p; } -static void remove_thread_from_proc(struct proc *p, struct thread *t) +static void remove_thread_from_team(struct team *p, struct thread *t) { struct thread *temp, *last = NULL; - for(temp = p->thread_list; temp != NULL; temp = temp->proc_next) { + for(temp = p->thread_list; temp != NULL; temp = temp->team_next) { if(temp == t) { if(last == NULL) { - p->thread_list = temp->proc_next; + p->thread_list = temp->team_next; } else { - last->proc_next = temp->proc_next; + last->team_next = temp->team_next; } p->num_threads--; break; @@ -322,7 +322,7 @@ static struct thread *create_thread_struct(const char *name) t->name[SYS_MAX_OS_NAME_LEN-1] = 0; t->id = atomic_add(&next_thread_id, 1); - t->proc = NULL; + t->team = NULL; t->cpu = NULL; t->sem_blocking = -1; t->fault_handler = 0; @@ -330,7 +330,7 @@ static struct thread *create_thread_struct(const char *name) t->kernel_stack_base = 0; t->user_stack_region_id = -1; t->user_stack_base = 0; - t->proc_next = NULL; + t->team_next = NULL; t->q_next = NULL; t->priority = -1; t->args = NULL; @@ -397,11 +397,11 @@ static int _create_kernel_thread_kentry(void) return func(t->args); } -static thread_id _create_thread(const char *name, proc_id pid, addr entry, void *args, +static thread_id _create_thread(const char *name, team_id pid, addr entry, void *args, int priority, bool kernel) { struct thread *t; - struct proc *p; + struct team *p; int state; char stack_name[64]; bool abort = false; @@ -421,15 +421,15 @@ static thread_id _create_thread(const char *name, proc_id pid, addr entry, void hash_insert(thread_hash, t); RELEASE_THREAD_LOCK(); - GRAB_PROC_LOCK(); - // look at the proc, make sure it's not being deleted - p = proc_get_proc_struct_locked(pid); - if(p != NULL && p->state != PROC_STATE_DEATH) { - insert_thread_into_proc(p, t); + GRAB_TEAM_LOCK(); + // look at the team, make sure it's not being deleted + p = team_get_team_struct_locked(pid); + if(p != NULL && p->state != TEAM_STATE_DEATH) { + insert_thread_into_team(p, t); } else { abort = true; } - RELEASE_PROC_LOCK(); + RELEASE_TEAM_LOCK(); if(abort) { GRAB_THREAD_LOCK(); hash_remove(thread_hash, t); @@ -485,7 +485,7 @@ static thread_id _create_thread(const char *name, proc_id pid, addr entry, void return t->id; } -thread_id user_thread_create_user_thread(addr entry, proc_id pid, const char *uname, int priority, +thread_id user_thread_create_user_thread(addr entry, team_id pid, const char *uname, int priority, void *args) { char name[SYS_MAX_OS_NAME_LEN]; @@ -504,17 +504,17 @@ thread_id user_thread_create_user_thread(addr entry, proc_id pid, const char *un return _create_thread(name, pid, entry, args, priority, false); } -thread_id thread_create_user_thread(char *name, proc_id pid, addr entry, void *args) +thread_id thread_create_user_thread(char *name, team_id pid, addr entry, void *args) { return _create_thread(name, pid, entry, args, -1, false); } thread_id thread_create_kernel_thread(const char *name, int (*func)(void *), void *args) { - return _create_thread(name, proc_get_kernel_proc()->id, (addr)func, args, -1, true); + return _create_thread(name, team_get_kernel_team()->id, (addr)func, args, -1, true); } -static thread_id thread_create_kernel_thread_etc(const char *name, int (*func)(void *), void *args, struct proc *p) +static thread_id thread_create_kernel_thread_etc(const char *name, int (*func)(void *), void *args, struct team *p) { return _create_thread(name, p->id, (addr)func, args, -1, true); } @@ -535,7 +535,7 @@ int thread_suspend_thread(thread_id id) } if (t != NULL) { - if (t->proc == kernel_proc) { + if (t->team == kernel_team) { // no way retval = EPERM; } else if (t->in_kernel == true) { @@ -629,9 +629,9 @@ int thread_set_priority(thread_id id, int priority) return retval; } -static void _dump_proc_info(struct proc *p) +static void _dump_team_info(struct team *p) { - dprintf("PROC: %p\n", p); + dprintf("TEAM: %p\n", p); dprintf("id: 0x%x\n", p->id); dprintf("name: '%s'\n", p->name); dprintf("next: %p\n", p->next); @@ -647,15 +647,15 @@ static void _dump_proc_info(struct proc *p) dprintf("thread_list: %p\n", p->thread_list); } -static int dump_proc_info(int argc, char **argv) +static int dump_team_info(int argc, char **argv) { - struct proc *p; + struct team *p; int id = -1; unsigned long num; struct hash_iterator i; if(argc < 2) { - dprintf("proc: not enough arguments\n"); + dprintf("team: not enough arguments\n"); return 0; } @@ -664,7 +664,7 @@ static int dump_proc_info(int argc, char **argv) num = atoul(argv[1]); if(num > vm_get_kernel_aspace()->virtual_map.base) { // XXX semi-hack - _dump_proc_info((struct proc*)num); + _dump_team_info((struct team*)num); return 0; } else { id = num; @@ -672,14 +672,14 @@ static int dump_proc_info(int argc, char **argv) } // walk through the thread list, trying to match name or id - hash_open(proc_hash, &i); - while((p = hash_next(proc_hash, &i)) != NULL) { + hash_open(team_hash, &i); + while((p = hash_next(team_hash, &i)) != NULL) { if((p->name && strcmp(argv[1], p->name) == 0) || p->id == id) { - _dump_proc_info(p); + _dump_team_info(p); break; } } - hash_close(proc_hash, &i, false); + hash_close(team_hash, &i, false); return 0; } @@ -711,8 +711,8 @@ static void _dump_thread_info(struct thread *t) dprintf("THREAD: %p\n", t); dprintf("id: 0x%x\n", t->id); dprintf("name: '%s'\n", t->name); - dprintf("all_next: %p\nproc_next: %p\nq_next: %p\n", - t->all_next, t->proc_next, t->q_next); + dprintf("all_next: %p\nteam_next: %p\nq_next: %p\n", + t->all_next, t->team_next, t->q_next); dprintf("priority: 0x%x\n", t->priority); dprintf("state: %s\n", state_to_text(t->state)); dprintf("next_state: %s\n", state_to_text(t->next_state)); @@ -731,7 +731,7 @@ static void _dump_thread_info(struct thread *t) dprintf("fault_handler: 0x%lx\n", t->fault_handler); dprintf("args: %p\n", t->args); dprintf("entry: 0x%lx\n", t->entry); - dprintf("proc: %p\n", t->proc); + dprintf("team: %p\n", t->team); dprintf("return_code_sem: 0x%x\n", t->return_code_sem); dprintf("kernel_stack_region_id: 0x%x\n", t->kernel_stack_region_id); dprintf("kernel_stack_base: 0x%lx\n", t->kernel_stack_base); @@ -841,7 +841,7 @@ static int dump_next_thread_in_all_list(int argc, char **argv) return 0; } -static int dump_next_thread_in_proc(int argc, char **argv) +static int dump_next_thread_in_team(int argc, char **argv) { struct thread *t = last_thread_dumped; @@ -850,9 +850,9 @@ static int dump_next_thread_in_proc(int argc, char **argv) return 0; } - dprintf("next thread in proc after thread @ %p\n", t); - if(t->proc_next != NULL) { - _dump_thread_info(t->proc_next); + dprintf("next thread in team after thread @ %p\n", t); + if(t->team_next != NULL) { + _dump_thread_info(t->team_next); } else { dprintf("NULL\n"); } @@ -924,24 +924,24 @@ int thread_init(kernel_args *ka) // dprintf("thread_init: entry\n"); - // create the process hash table - proc_hash = hash_init(15, (addr)&kernel_proc->next - (addr)kernel_proc, - &proc_struct_compare, &proc_struct_hash); + // create the team hash table + team_hash = hash_init(15, (addr)&kernel_team->next - (addr)kernel_team, + &team_struct_compare, &team_struct_hash); - // create the kernel process - kernel_proc = create_proc_struct("kernel_proc", true); - if(kernel_proc == NULL) - panic("could not create kernel proc!\n"); - kernel_proc->state = PROC_STATE_NORMAL; + // create the kernel team + kernel_team = create_team_struct("kernel_team", true); + if(kernel_team == NULL) + panic("could not create kernel team!\n"); + kernel_team->state = TEAM_STATE_NORMAL; - kernel_proc->ioctx = vfs_new_io_context(NULL); - if(kernel_proc->ioctx == NULL) - panic("could not create ioctx for kernel proc!\n"); + kernel_team->ioctx = vfs_new_io_context(NULL); + if(kernel_team->ioctx == NULL) + panic("could not create ioctx for kernel team!\n"); - //XXX should initialize kernel_proc->path here. Set it to "/"? + //XXX should initialize kernel_team->path here. Set it to "/"? - // stick it in the process hash - hash_insert(proc_hash, kernel_proc); + // stick it in the team hash + hash_insert(team_hash, kernel_team); // create the thread hash table thread_hash = hash_init(15, (addr)&t->all_next - (addr)t, @@ -971,7 +971,7 @@ int thread_init(kernel_args *ka) panic("error creating idle thread struct\n"); return ENOMEM; } - t->proc = proc_get_kernel_proc(); + t->team = team_get_kernel_team(); t->priority = THREAD_IDLE_PRIORITY; t->state = THREAD_STATE_RUNNING; t->next_state = THREAD_STATE_READY; @@ -984,7 +984,7 @@ int thread_init(kernel_args *ka) t->kernel_stack_base = region->base; vm_put_region(region); hash_insert(thread_hash, t); - insert_thread_into_proc(t->proc, t); + insert_thread_into_team(t->team, t); idle_threads[i] = t; if(i == 0) arch_thread_set_current_thread(t); @@ -1027,8 +1027,8 @@ int thread_init(kernel_args *ka) add_debugger_command("thread", &dump_thread_info, "list info about a particular thread"); add_debugger_command("next_q", &dump_next_thread_in_q, "dump the next thread in the queue of last thread viewed"); add_debugger_command("next_all", &dump_next_thread_in_all_list, "dump the next thread in the global list of the last thread viewed"); - add_debugger_command("next_proc", &dump_next_thread_in_proc, "dump the next thread in the process of the last thread viewed"); - add_debugger_command("proc", &dump_proc_info, "list info about a particular process"); + add_debugger_command("next_team", &dump_next_thread_in_team, "dump the next thread in the team of the last thread viewed"); + add_debugger_command("team", &dump_team_info, "list info about a particular team"); return 0; } @@ -1120,9 +1120,9 @@ static void thread_exit2(void *_args) // remove this thread from all of the global lists disable_interrupts(); - GRAB_PROC_LOCK(); - remove_thread_from_proc(kernel_proc, args.t); - RELEASE_PROC_LOCK(); + GRAB_TEAM_LOCK(); + remove_thread_from_team(kernel_team, args.t); + RELEASE_TEAM_LOCK(); GRAB_THREAD_LOCK(); hash_remove(thread_hash, args.t); RELEASE_THREAD_LOCK(); @@ -1145,8 +1145,8 @@ void thread_exit(int retcode) { int state; struct thread *t = thread_get_current_thread(); - struct proc *p = t->proc; - bool delete_proc = false; + struct team *p = t->team; + bool delete_team = false; unsigned int death_stack; sem_id cached_death_sem; @@ -1162,22 +1162,22 @@ void thread_exit(int retcode) vm_delete_region(p->_aspace_id, rid); } - if(p != kernel_proc) { - // remove this thread from the current process and add it to the kernel - // put the thread into the kernel proc until it dies + if(p != kernel_team) { + // remove this thread from the current team and add it to the kernel + // put the thread into the kernel team until it dies state = disable_interrupts(); - GRAB_PROC_LOCK(); - remove_thread_from_proc(p, t); - insert_thread_into_proc(kernel_proc, t); + GRAB_TEAM_LOCK(); + remove_thread_from_team(p, t); + insert_thread_into_team(kernel_team, t); if(p->main_thread == t) { - // this was main thread in this process - delete_proc = true; - hash_remove(proc_hash, p); - p->state = PROC_STATE_DEATH; + // this was main thread in this team + delete_team = true; + hash_remove(team_hash, p); + p->state = TEAM_STATE_DEATH; } - RELEASE_PROC_LOCK(); + RELEASE_TEAM_LOCK(); // swap address spaces, to make sure we're running on the kernel's pgdir - vm_aspace_swap(kernel_proc->kaspace); + vm_aspace_swap(kernel_team->kaspace); restore_interrupts(state); // dprintf("thread_exit: thread 0x%x now a kernel thread!\n", t->id); @@ -1185,10 +1185,10 @@ void thread_exit(int retcode) cached_death_sem = p->death_sem; - // delete the process - if(delete_proc) { + // delete the team + if(delete_team) { if(p->num_threads > 0) { - // there are other threads still in this process, + // there are other threads still in this team, // cycle through and signal kill on each of the threads // XXX this can be optimized. There's got to be a better solution. struct thread *temp_thread; @@ -1200,16 +1200,16 @@ void thread_exit(int retcode) panic("thread_exit: cannot init death sem for team %d\n", p->id); state = disable_interrupts(); - GRAB_PROC_LOCK(); + GRAB_TEAM_LOCK(); // we can safely walk the list because of the lock. no new threads can be created - // because of the PROC_STATE_DEATH flag on the process + // because of the TEAM_STATE_DEATH flag on the team temp_thread = p->thread_list; while(temp_thread) { - struct thread *next = temp_thread->proc_next; + struct thread *next = temp_thread->team_next; thread_kill_thread_nowait(temp_thread->id); temp_thread = next; } - RELEASE_PROC_LOCK(); + RELEASE_TEAM_LOCK(); restore_interrupts(state); #if 0 // Now wait for all of the threads to die @@ -1276,7 +1276,7 @@ static int _thread_kill_thread(thread_id id, bool wait_on) t = thread_get_thread_struct_locked(id); if(t != NULL) { - if(t->proc == kernel_proc) { + if(t->team == kernel_team) { // can't touch this rc = EPERM; } else { @@ -1373,7 +1373,7 @@ int thread_wait_on_thread(thread_id id, int *retcode) return rc; } -int user_proc_wait_on_proc(proc_id id, int *uretcode) +int user_team_wait_on_team(team_id id, int *uretcode) { int retcode; int rc, rc2; @@ -1381,7 +1381,7 @@ int user_proc_wait_on_proc(proc_id id, int *uretcode) if((addr)uretcode >= KERNEL_BASE && (addr)uretcode <= KERNEL_TOP) return ERR_VM_BAD_USER_MEMORY; - rc = proc_wait_on_proc(id, &retcode); + rc = team_wait_on_team(id, &retcode); if(rc < 0) return rc; @@ -1392,21 +1392,21 @@ int user_proc_wait_on_proc(proc_id id, int *uretcode) return rc; } -int proc_wait_on_proc(proc_id id, int *retcode) +int team_wait_on_team(team_id id, int *retcode) { - struct proc *p; + struct team *p; thread_id tid; int state; state = disable_interrupts(); - GRAB_PROC_LOCK(); - p = proc_get_proc_struct_locked(id); + GRAB_TEAM_LOCK(); + p = team_get_team_struct_locked(id); if(p && p->main_thread) { tid = p->main_thread->id; } else { tid = ERR_INVALID_HANDLE; } - RELEASE_PROC_LOCK(); + RELEASE_TEAM_LOCK(); restore_interrupts(state); if(tid < 0) @@ -1441,30 +1441,30 @@ static struct thread *thread_get_thread_struct_locked(thread_id id) } /* XXX - static but unused -static struct proc *proc_get_proc_struct(proc_id id) +static struct team *team_get_team_struct(team_id id) { - struct proc *p; + struct team *p; int state; state = disable_interrupts(); - GRAB_PROC_LOCK(); + GRAB_TEAM_LOCK(); - p = proc_get_proc_struct_locked(id); + p = team_get_team_struct_locked(id); - RELEASE_PROC_LOCK(); + RELEASE_TEAM_LOCK(); restore_interrupts(state); return p; } */ -static struct proc *proc_get_proc_struct_locked(proc_id id) +static struct team *team_get_team_struct_locked(team_id id) { - struct proc_key key; + struct team_key key; key.id = id; - return hash_lookup(proc_hash, &key); + return hash_lookup(team_hash, &key); } static void thread_context_switch(struct thread *t_from, struct thread *t_to) @@ -1602,19 +1602,19 @@ found_thread: #endif } -static int proc_struct_compare(void *_p, const void *_key) +static int team_struct_compare(void *_p, const void *_key) { - struct proc *p = _p; - const struct proc_key *key = _key; + struct team *p = _p; + const struct team_key *key = _key; if(p->id == key->id) return 0; else return 1; } -static unsigned int proc_struct_hash(void *_p, const void *_key, unsigned int range) +static unsigned int team_struct_hash(void *_p, const void *_key, unsigned int range) { - struct proc *p = _p; - const struct proc_key *key = _key; + struct team *p = _p; + const struct team_key *key = _key; if(p != NULL) return (p->id % range); @@ -1622,32 +1622,32 @@ static unsigned int proc_struct_hash(void *_p, const void *_key, unsigned int ra return (key->id % range); } -struct proc *proc_get_kernel_proc(void) +struct team *team_get_kernel_team(void) { - return kernel_proc; + return kernel_team; } -proc_id proc_get_kernel_proc_id(void) +team_id team_get_kernel_team_id(void) { - if(!kernel_proc) + if(!kernel_team) return 0; else - return kernel_proc->id; + return kernel_team->id; } -proc_id proc_get_current_proc_id(void) +team_id team_get_current_team_id(void) { - return thread_get_current_thread()->proc->id; + return thread_get_current_thread()->team->id; } -static struct proc *create_proc_struct(const char *name, bool kernel) +static struct team *create_team_struct(const char *name, bool kernel) { - struct proc *p; + struct team *p; - p = (struct proc *)kmalloc(sizeof(struct proc)); + p = (struct team *)kmalloc(sizeof(struct team)); if(p == NULL) goto error; - p->id = atomic_add(&next_proc_id, 1); + p->id = atomic_add(&next_team_id, 1); strncpy(&p->name[0], name, SYS_MAX_OS_NAME_LEN-1); p->name[SYS_MAX_OS_NAME_LEN-1] = 0; p->num_threads = 0; @@ -1659,12 +1659,12 @@ static struct proc *create_proc_struct(const char *name, bool kernel) vm_put_aspace(p->kaspace); p->thread_list = NULL; p->main_thread = NULL; - p->state = PROC_STATE_BIRTH; + p->state = TEAM_STATE_BIRTH; p->pending_signals = SIG_NONE; p->death_sem = -1; p->user_env_base = NULL; - if(arch_proc_init_proc_struct(p, kernel) < 0) + if(arch_team_init_team_struct(p, kernel) < 0) goto error1; return p; @@ -1675,7 +1675,7 @@ error: return NULL; } -static void delete_proc_struct(struct proc *p) +static void delete_team_struct(struct team *p) { kfree(p); } @@ -1692,12 +1692,12 @@ static int get_arguments_data_size(char **args,int argc) return tot_size + sizeof(struct uspace_prog_args_t); } -static int proc_create_proc2(void *args) +static int team_create_team2(void *args) { int err; struct thread *t; - struct proc *p; - struct proc_arg *pargs = args; + struct team *p; + struct team_arg *pargs = args; char *path; addr entry; char ustack_name[128]; @@ -1710,9 +1710,9 @@ static int proc_create_proc2(void *args) unsigned int env_cnt; t = thread_get_current_thread(); - p = t->proc; + p = t->team; - dprintf("proc_create_proc2: entry thread %d\n", t->id); + dprintf("team_create_team2: entry thread %d\n", t->id); // create an initial primary stack region @@ -1722,7 +1722,7 @@ static int proc_create_proc2(void *args) t->user_stack_region_id = vm_create_anonymous_region(p->_aspace_id, ustack_name, (void **)&t->user_stack_base, REGION_ADDR_EXACT_ADDRESS, tot_top_size, REGION_WIRING_LAZY, LOCK_RW); if(t->user_stack_region_id < 0) { - panic("proc_create_proc2: could not create default user stack region\n"); + panic("team_create_team2: could not create default user stack region\n"); return t->user_stack_region_id; } @@ -1741,7 +1741,7 @@ static int proc_create_proc2(void *args) p->user_env_base = t->user_stack_base + STACK_SIZE; uenv = (char **)p->user_env_base; udest = (char *)p->user_env_base + ENV_SIZE - 1; -// dprintf("proc_create_proc2: envc: %d, envp: 0x%p\n", pargs->envc, (void *)pargs->envp); +// dprintf("team_create_team2: envc: %d, envp: 0x%p\n", pargs->envc, (void *)pargs->envp); for (env_cnt=0; env_cntenvc; env_cnt++) { udest -= (strlen(pargs->envp[env_cnt]) + 1); uenv[env_cnt] = udest; @@ -1762,11 +1762,11 @@ static int proc_create_proc2(void *args) kfree_strings_array(pargs->envp, pargs->envc); path = pargs->path; - dprintf("proc_create_proc2: loading elf binary '%s'\n", path); + dprintf("team_create_team2: loading elf binary '%s'\n", path); err = elf_load_uspace("/boot/libexec/rld.so", p, 0, &entry); if(err < 0){ - // XXX clean up proc + // XXX clean up team return err; } @@ -1774,9 +1774,9 @@ static int proc_create_proc2(void *args) kfree(pargs->path); kfree(pargs); - dprintf("proc_create_proc2: loaded elf. entry = 0x%lx\n", entry); + dprintf("team_create_team2: loaded elf. entry = 0x%lx\n", entry); - p->state = PROC_STATE_NORMAL; + p->state = TEAM_STATE_NORMAL; // jump to the entry point in user space arch_thread_enter_uspace(entry, uspa, t->user_stack_base + STACK_SIZE); @@ -1785,32 +1785,32 @@ static int proc_create_proc2(void *args) return 0; } -proc_id proc_create_proc(const char *path, const char *name, char **args, int argc, char **envp, int envc, int priority) +team_id team_create_team(const char *path, const char *name, char **args, int argc, char **envp, int envc, int priority) { - struct proc *p; + struct team *p; thread_id tid; - proc_id pid; + team_id pid; int err; unsigned int state; // int sem_retcode; - struct proc_arg *pargs; + struct team_arg *pargs; - dprintf("proc_create_proc: entry '%s', name '%s' args = %p argc = %d\n", path, name, args, argc); + dprintf("team_create_team: entry '%s', name '%s' args = %p argc = %d\n", path, name, args, argc); - p = create_proc_struct(name, false); + p = create_team_struct(name, false); if(p == NULL) return ENOMEM; pid = p->id; state = disable_interrupts(); - GRAB_PROC_LOCK(); - hash_insert(proc_hash, p); - RELEASE_PROC_LOCK(); + GRAB_TEAM_LOCK(); + hash_insert(team_hash, p); + RELEASE_TEAM_LOCK(); restore_interrupts(state); // copy the args over - pargs = (struct proc_arg *)kmalloc(sizeof(struct proc_arg)); + pargs = (struct team_arg *)kmalloc(sizeof(struct team_arg)); if(pargs == NULL){ err = ENOMEM; goto err1; @@ -1825,8 +1825,8 @@ proc_id proc_create_proc(const char *path, const char *name, char **args, int ar pargs->envp = envp; pargs->envc = envc; - // create a new ioctx for this process - p->ioctx = vfs_new_io_context(thread_get_current_thread()->proc->ioctx); + // create a new ioctx for this team + p->ioctx = vfs_new_io_context(thread_get_current_thread()->team->ioctx); if(!p->ioctx) { err = ENOMEM; goto err3; @@ -1834,7 +1834,7 @@ proc_id proc_create_proc(const char *path, const char *name, char **args, int ar //XXX should set p->path to path(?) here. - // create an address space for this process + // create an address space for this team p->_aspace_id = vm_create_aspace(p->name, USER_BASE, USER_SIZE, false); if (p->_aspace_id < 0) { err = p->_aspace_id; @@ -1842,8 +1842,8 @@ proc_id proc_create_proc(const char *path, const char *name, char **args, int ar } p->aspace = vm_get_aspace_by_id(p->_aspace_id); - // create a kernel thread, but under the context of the new process - tid = thread_create_kernel_thread_etc(name, proc_create_proc2, pargs, p); + // create a kernel thread, but under the context of the new team + tid = thread_create_kernel_thread_etc(name, team_create_team2, pargs, p); if (tid < 0) { err = tid; goto err5; @@ -1863,18 +1863,18 @@ err3: err2: kfree(pargs); err1: - // remove the proc structure from the proc hash table and delete the proc structure + // remove the team structure from the team hash table and delete the team structure state = disable_interrupts(); - GRAB_PROC_LOCK(); - hash_remove(proc_hash, p); - RELEASE_PROC_LOCK(); + GRAB_TEAM_LOCK(); + hash_remove(team_hash, p); + RELEASE_TEAM_LOCK(); restore_interrupts(state); - delete_proc_struct(p); + delete_team_struct(p); //err: return err; } -proc_id user_proc_create_proc(const char *upath, const char *uname, char **args, int argc, char **envp, int envc, int priority) +team_id user_team_create_team(const char *upath, const char *uname, char **args, int argc, char **envp, int envc, int priority) { char path[SYS_MAX_PATH_LEN]; char name[SYS_MAX_OS_NAME_LEN]; @@ -1882,7 +1882,7 @@ proc_id user_proc_create_proc(const char *upath, const char *uname, char **args, char **kenv; int rc; - dprintf("user_proc_create_proc : argc=%d \n",argc); + dprintf("user_team_create_team : argc=%d \n",argc); if ((addr)upath >= KERNEL_BASE && (addr)upath <= KERNEL_TOP) return ERR_VM_BAD_USER_MEMORY; @@ -1894,7 +1894,7 @@ proc_id user_proc_create_proc(const char *upath, const char *uname, char **args, goto error; if (envp == NULL) { - envp = (char **)thread_get_current_thread()->proc->user_env_base; + envp = (char **)thread_get_current_thread()->team->user_env_base; for (envc = 0; envp && (envp[envc]); envc++); } rc = user_copy_strings_array(envp, envc, &kenv); @@ -1913,7 +1913,7 @@ proc_id user_proc_create_proc(const char *upath, const char *uname, char **args, name[SYS_MAX_OS_NAME_LEN-1] = 0; - return proc_create_proc(path, name, kargs, argc, kenv, envc, priority); + return team_create_team(path, name, kargs, argc, kenv, envc, priority); error: kfree_strings_array(kargs, argc); kfree_strings_array(kenv, envc); @@ -1921,69 +1921,72 @@ error: } -// used by PS command and anything else interested in a process list -int user_proc_get_table(struct proc_info *pbuf, size_t len) +// used by PS command and anything else interested in a team list +int user_team_get_table(team_info *pbuf, size_t len) { - struct proc *p; +#if 0 + struct team *p; struct hash_iterator i; - struct proc_info pi; + struct team_info pi; int state; int count=0; - int max = (len / sizeof(struct proc_info)); + int max = (len / sizeof(struct team_info)); if((addr)pbuf >= KERNEL_BASE && (addr)pbuf <= KERNEL_TOP) return ERR_VM_BAD_USER_MEMORY; state = disable_interrupts(); - GRAB_PROC_LOCK(); + GRAB_TEAM_LOCK(); - hash_open(proc_hash, &i); - while(((p = hash_next(proc_hash, &i)) != NULL) && (count < max)) { + hash_open(team_hash, &i); + while(((p = hash_next(team_hash, &i)) != NULL) && (count < max)) { pi.id = p->id; strcpy(pi.name, p->name); pi.state = p->state; pi.num_threads = p->num_threads; count++; - user_memcpy(pbuf, &pi, sizeof(struct proc_info)); - pbuf=pbuf + sizeof(struct proc_info); + user_memcpy(pbuf, &pi, sizeof(struct team_info)); + pbuf=pbuf + sizeof(struct team_info); } - hash_close(proc_hash, &i, false); + hash_close(team_hash, &i, false); - RELEASE_PROC_LOCK(); + RELEASE_TEAM_LOCK(); restore_interrupts(state); if (count < max) return count; else return ENOMEM; +#endif + return 0; } -int proc_kill_proc(proc_id id) +int team_kill_team(team_id id) { int state; - struct proc *p; + struct team *p; // struct thread *t; thread_id tid = -1; int retval = 0; state = disable_interrupts(); - GRAB_PROC_LOCK(); + GRAB_TEAM_LOCK(); - p = proc_get_proc_struct_locked(id); + p = team_get_team_struct_locked(id); if(p != NULL) { tid = p->main_thread->id; } else { retval = ERR_INVALID_HANDLE; } - RELEASE_PROC_LOCK(); + RELEASE_TEAM_LOCK(); restore_interrupts(state); if(retval < 0) return retval; - // just kill the main thread in the process. The cleanup code there will - // take care of the process + // just kill the main thread in the team. The cleanup code there will + // take care of the team return thread_kill_thread(tid); } @@ -2217,14 +2220,14 @@ int sys_setenv(const char *name, const char *value, int overwrite) return -1; state = disable_interrupts(); - GRAB_PROC_LOCK(); + GRAB_TEAM_LOCK(); strcpy(var, name); strncat(var, "=", SYS_THREAD_STRING_LENGTH_MAX-1); name_size = strlen(var); strncat(var, value, SYS_THREAD_STRING_LENGTH_MAX-1); - env_space = (addr)thread_get_current_thread()->proc->user_env_base; + env_space = (addr)thread_get_current_thread()->team->user_env_base; envp = (char **)env_space; for (envc=0; envp[envc]; envc++) { if (!strncmp(envp[envc], var, name_size)) { @@ -2273,7 +2276,7 @@ int sys_setenv(const char *name, const char *value, int overwrite) } dprintf("sys_setenv: variable set.\n"); - RELEASE_PROC_LOCK(); + RELEASE_TEAM_LOCK(); restore_interrupts(state); return rc; @@ -2317,9 +2320,9 @@ int sys_getenv(const char *name, char **value) int rc = -1; state = disable_interrupts(); - GRAB_PROC_LOCK(); + GRAB_TEAM_LOCK(); - envp = (char **)thread_get_current_thread()->proc->user_env_base; + envp = (char **)thread_get_current_thread()->team->user_env_base; for (i=0; envp[i]; i++) { if (!strncmp(envp[i], name, len)) { p = envp[i] + len; @@ -2331,7 +2334,7 @@ int sys_getenv(const char *name, char **value) } } - RELEASE_PROC_LOCK(); + RELEASE_TEAM_LOCK(); restore_interrupts(state); return rc; diff --git a/src/kernel/core/vm/vm.c b/src/kernel/core/vm/vm.c index 5ea9a0a58d..35e233d333 100755 --- a/src/kernel/core/vm/vm.c +++ b/src/kernel/core/vm/vm.c @@ -1440,7 +1440,7 @@ aspace_id vm_get_current_user_aspace_id(void) struct thread *t = thread_get_current_thread(); if(t) - return t->proc->_aspace_id; + return t->team->_aspace_id; else return -1; } @@ -1813,8 +1813,8 @@ int vm_page_fault(addr address, addr fault_address, bool is_write, bool is_user, address, fault_address); } } else { - dprintf("vm_page_fault: killing process 0x%x\n", thread_get_current_thread()->proc->id); - proc_kill_proc(thread_get_current_thread()->proc->id); + dprintf("vm_page_fault: killing team 0x%x\n", thread_get_current_thread()->team->id); + team_kill_team(thread_get_current_thread()->team->id); } } diff --git a/src/kernel/libroot/libroot.c b/src/kernel/libroot/libroot.c index 23918953e0..5093fa9f1d 100755 --- a/src/kernel/libroot/libroot.c +++ b/src/kernel/libroot/libroot.c @@ -102,27 +102,27 @@ status_t _get_port_info(port_id port, port_info *info, size_t size) { return sys // OK sem_id create_sem(int32 count, const char *name) -{ return kern_create_sem(count,name); } +{ return sys_create_sem(count,name); } // OK status_t delete_sem(sem_id sem) -{ return kern_delete_sem(sem); } +{ return sys_delete_sem(sem); } // OK status_t acquire_sem(sem_id sem) -{ return kern_acquire_sem(sem); } +{ return sys_acquire_sem(sem); } // Have to modify flags ??? int acquire_sem_etc(sem_id sem, int32 count, int32 flags, bigtime_t timeout) -{ return kern_acquire_sem_etc(sem, count, flags, timeout); } +{ return sys_acquire_sem_etc(sem, count, flags, timeout); } // OK status_t release_sem(sem_id sem) -{ return kern_release_sem(sem); } +{ return sys_release_sem(sem); } // Have to modify flags ??? status_t release_sem_etc(sem_id sem, int32 count, int32 flags) -{ return kern_release_sem_etc(sem, count, flags); } +{ return sys_release_sem_etc(sem, count, flags); } // OK status_t get_sem_count(sem_id sem, int32 *count) @@ -134,32 +134,32 @@ status_t set_sem_owner(sem_id sem, team_id team) // OK status_t _get_sem_info(sem_id sem, sem_info *info, size_t size) -{ return kern_get_sem_info(sem,info, size); } +{ return sys_get_sem_info(sem,info, size); } // OK -int _get_next_sem_info(proc_id team, uint32 *cookie, sem_info *info, size_t size) -{ return kern_get_next_sem_info(team,cookie,info, size); } +int _get_next_sem_info(team_id team, uint32 *cookie, sem_info *info, size_t size) +{ return sys_get_next_sem_info(team,cookie,info, size); } // TO DO bigtime_t set_alarm(bigtime_t when, uint32 flags); // case SYSCALL_GET_CURRENT_THREAD_ID: *call_ret = thread_get_current_thread_id(); break; -// case SYSCALL_THREAD_CREATE_THREAD: *call_ret = user_thread_create_user_thread((char *)arg0, thread_get_current_thread()->proc->id, (addr)arg1, (void *)arg2); break; +// case SYSCALL_THREAD_CREATE_THREAD: *call_ret = user_thread_create_user_thread((char *)arg0, thread_get_current_thread()->team->id, (addr)arg1, (void *)arg2); break; // case SYSCALL_PROC_CREATE_PROC: *call_ret = user_proc_create_proc((const char *)arg0, (const char *)arg1, (char **)arg2, (int )arg3, (int)arg4); break; // case SYSCALL_GET_CURRENT_PROC_ID: *call_ret = proc_get_current_proc_id(); break; // case SYSCALL_PROC_WAIT_ON_PROC: *call_ret = user_proc_wait_on_proc((proc_id)arg0, (int *)arg1); break; // OK status_t kill_thread(thread_id thread) - { return kern_kill_thread(thread); } + { return sys_kill_thread(thread); } // OK status_t resume_thread(thread_id thread) - { return kern_resume_thread(thread); } + { return sys_resume_thread(thread); } // OK status_t suspend_thread(thread_id thread) - { return kern_suspend_thread(thread); } + { return sys_suspend_thread(thread); } // TO DO status_t rename_thread(thread_id thread, const char *new_name); @@ -172,7 +172,7 @@ void exit_thread(status_t status) // OK status_t wait_for_thread (thread_id thread, status_t *thread_return_value) - { return sys_thread_wait_on_thread(thread,thread_return_value); } + { return sys_wait_on_thread(thread,thread_return_value); } // TO DO status_t on_exit_thread(void (*callback)(void *), void *data); @@ -202,7 +202,7 @@ status_t snooze_until(bigtime_t time, int timebase); // OK status_t kill_team(team_id team) - { return sys_proc_kill_proc(team); } + { return sys_kill_team(team); } // TO DO status_t _get_team_info(team_id team, team_info *info, size_t size); diff --git a/src/kernel/libroot/libroot_types.h b/src/kernel/libroot/libroot_types.h index f7ae4e4330..afe97959d9 100755 --- a/src/kernel/libroot/libroot_types.h +++ b/src/kernel/libroot/libroot_types.h @@ -47,20 +47,6 @@ enum { #define B_SYSTEM_TIMEBASE (0) #define B_SYSTEM_TEAM 2 -typedef struct { - team_id team; - int32 image_count; - int32 thread_count; - int32 area_count; - thread_id debugger_nub_thread; - port_id debugger_nub_port; - - int32 argc; /* number of args on the command line */ - char args[64]; /* abbreviated command line args */ - uid_t uid; - gid_t gid; -} team_info; - #if __INTEL__ #define B_MAX_CPU_COUNT 8 #endif