Changeset e5a1f82f in mainline


Ignore:
Timestamp:
2006-03-17T18:09:15Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
81e55099
Parents:
11a4fbf
Message:

Improved uspace threads (uspace).

Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • init/init.c

    r11a4fbf re5a1f82f  
    3838void utest(void *arg)
    3939{
    40 //      printf("Uspace thread created.\n");
     40//      printf("Uspace thread started.\n");
    4141        for (;;)
    4242                ;
     
    190190{
    191191        int tid;
    192         char *stack;
    193192        version_print();
    194193
     
    199198        test_connection_ipc();
    200199       
    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);
    208202        }
    209203       
  • libc/Makefile

    r11a4fbf re5a1f82f  
    5252
    5353ARCH_SOURCES += \
    54         arch/$(ARCH)/src/entry.s
     54        arch/$(ARCH)/src/entry.s \
     55        arch/$(ARCH)/src/thread_entry.s
    5556
    5657GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
  • libc/arch/ia64/src/entry.s

    r11a4fbf re5a1f82f  
    3737#
    3838__entry:
     39        alloc loc0 = ar.pfs, 0, 1, 2, 0
    3940        mov r1 = _gp
    4041        { br.call.sptk.many b0 = main }
  • libc/generic/thread.c

    r11a4fbf re5a1f82f  
    2929#include <thread.h>
    3030#include <libc.h>
     31#include <stdlib.h>
    3132#include <arch/faddr.h>
     33#include <kernel/proc/uarg.h>
    3234
    33 typedef void (* voidfunc_t)(void);
     35void 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}
    3442
    35 int thread_create(void (* function)(void *), void *arg, void *stack, char *name)
     43int thread_create(void (* function)(void *), void *arg, char *name)
    3644{
    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);
    3864}
    3965
     
    4268        __SYSCALL1(SYS_THREAD_EXIT, (sysarg_t) status);
    4369}
    44 
  • libc/include/thread.h

    r11a4fbf re5a1f82f  
    3030#define __LIBC__THREAD_H__
    3131
    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
     34extern void __thread_entry(void);
     35extern void thread_main(uspace_arg_t *uarg);
     36
     37extern int thread_create(void (* function)(void *arg), void *arg, char *name);
     38extern void thread_exit(int status);
    3439
    3540#endif
Note: See TracChangeset for help on using the changeset viewer.