Changeset e5a1f82f in mainline
- Timestamp:
- 2006-03-17T18:09:15Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 81e55099
- Parents:
- 11a4fbf
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
init/init.c
r11a4fbf re5a1f82f 38 38 void utest(void *arg) 39 39 { 40 // printf("Uspace thread created.\n");40 // printf("Uspace thread started.\n"); 41 41 for (;;) 42 42 ; … … 190 190 { 191 191 int tid; 192 char *stack;193 192 version_print(); 194 193 … … 199 198 test_connection_ipc(); 200 199 201 stack = (char *) malloc(getpagesize()); 202 if (!stack) { 203 printf("Malloc failed.\n"); 204 } else { 205 if ((tid = thread_create(utest, NULL, stack, "utest") != -1)) { 206 printf("Created thread tid=%d\n", tid); 207 } 200 if ((tid = thread_create(utest, NULL, "utest") != -1)) { 201 printf("Created thread tid=%d\n", tid); 208 202 } 209 203 -
libc/Makefile
r11a4fbf re5a1f82f 52 52 53 53 ARCH_SOURCES += \ 54 arch/$(ARCH)/src/entry.s 54 arch/$(ARCH)/src/entry.s \ 55 arch/$(ARCH)/src/thread_entry.s 55 56 56 57 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) -
libc/arch/ia64/src/entry.s
r11a4fbf re5a1f82f 37 37 # 38 38 __entry: 39 alloc loc0 = ar.pfs, 0, 1, 2, 0 39 40 mov r1 = _gp 40 41 { br.call.sptk.many b0 = main } -
libc/generic/thread.c
r11a4fbf re5a1f82f 29 29 #include <thread.h> 30 30 #include <libc.h> 31 #include <stdlib.h> 31 32 #include <arch/faddr.h> 33 #include <kernel/proc/uarg.h> 32 34 33 typedef void (* voidfunc_t)(void); 35 void thread_main(uspace_arg_t *uarg) 36 { 37 uarg->uspace_thread_function(uarg->uspace_thread_arg); 38 free(uarg->uspace_stack); 39 free(uarg); 40 thread_exit(0); 41 } 34 42 35 int thread_create(void (* function)(void *), void *arg, void *stack,char *name)43 int thread_create(void (* function)(void *), void *arg, char *name) 36 44 { 37 return __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) FADDR((voidfunc_t) function), (sysarg_t) arg, (sysarg_t) stack, (sysarg_t) name); 45 char *stack; 46 uspace_arg_t *uarg; 47 48 stack = (char *) malloc(getpagesize()); 49 if (!stack) 50 return -1; 51 52 uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t)); 53 if (!uarg) { 54 free(stack); 55 return -1; 56 } 57 uarg->uspace_entry = (void *) FADDR(__thread_entry); 58 uarg->uspace_stack = (void *) stack; 59 uarg->uspace_thread_function = (void *) FADDR(function); 60 uarg->uspace_thread_arg = arg; 61 uarg->uspace_uarg = uarg; 62 63 return __SYSCALL2(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name); 38 64 } 39 65 … … 42 68 __SYSCALL1(SYS_THREAD_EXIT, (sysarg_t) status); 43 69 } 44 -
libc/include/thread.h
r11a4fbf re5a1f82f 30 30 #define __LIBC__THREAD_H__ 31 31 32 int thread_create(void (* function)(void *arg), void *arg, void *stack, char *name); 33 void thread_exit(int status); 32 #include <kernel/proc/uarg.h> 33 34 extern void __thread_entry(void); 35 extern void thread_main(uspace_arg_t *uarg); 36 37 extern int thread_create(void (* function)(void *arg), void *arg, char *name); 38 extern void thread_exit(int status); 34 39 35 40 #endif
Note:
See TracChangeset
for help on using the changeset viewer.