Changeset 0f250f9 in mainline for generic


Ignore:
Timestamp:
2006-03-17T18:07:56Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
69f293e
Parents:
6c6a19e6
Message:

Improved uspace threads.
ia64 needs fixing.

Location:
generic
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • generic/include/proc/thread.h

    r6c6a19e6 r0f250f9  
    4141#include <adt/list.h>
    4242#include <mm/slab.h>
     43#include <proc/uarg.h>
    4344
    4445#define THREAD_STACK_SIZE       STACK_SIZE
     
    118119};
    119120
    120 /** Structure passed to uinit kernel thread as argument. */
    121 typedef struct uspace_arg {
    122         __address uspace_entry;
    123         __address uspace_stack;
    124 } uspace_arg_t;
    125 
    126121/** Thread list lock.
    127122 *
     
    150145
    151146/** Thread syscall prototypes. */
    152 __native sys_thread_create(__address function, void *arg, void *stack, char *name);
    153 __native sys_thread_exit(int status);
     147__native sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name);
     148__native sys_thread_exit(int uspace_status);
    154149
    155150#endif
  • generic/src/main/uinit.c

    r6c6a19e6 r0f250f9  
    4444        uarg.uspace_entry = ((uspace_arg_t *) arg)->uspace_entry;
    4545        uarg.uspace_stack = ((uspace_arg_t *) arg)->uspace_stack;
     46        uarg.uspace_uarg = ((uspace_arg_t *) arg)->uspace_uarg;
     47        uarg.uspace_thread_function = NULL;
     48        uarg.uspace_thread_arg = NULL;
    4649
    4750        free((uspace_arg_t *) arg);
  • generic/src/proc/task.c

    r6c6a19e6 r0f250f9  
    3030#include <proc/thread.h>
    3131#include <proc/task.h>
     32#include <proc/uarg.h>
    3233#include <mm/as.h>
    3334#include <mm/slab.h>
    34 
    3535#include <synch/spinlock.h>
    3636#include <arch.h>
     
    4040#include <memstr.h>
    4141#include <print.h>
    42 
    4342#include <elf.h>
    4443
     
    116115        thread_t *t;
    117116        task_t *task;
    118         uspace_arg_t *uarg;
     117        uspace_arg_t *kernel_uarg;
    119118
    120119        as = as_create(0);
     
    126125        }
    127126       
    128         uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);
    129         uarg->uspace_entry = (__address) ((elf_header_t *) program_addr)->e_entry;
    130         uarg->uspace_stack = USTACK_ADDRESS;
     127        kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);
     128        kernel_uarg->uspace_entry = (void *) ((elf_header_t *) program_addr)->e_entry;
     129        kernel_uarg->uspace_stack = (void *) USTACK_ADDRESS;
     130        kernel_uarg->uspace_thread_function = NULL;
     131        kernel_uarg->uspace_thread_arg = NULL;
     132        kernel_uarg->uspace_uarg = NULL;
    131133       
    132134        task = task_create(as, name);
    133         t = thread_create(uinit, uarg, task, 0, "uinit");
     135        t = thread_create(uinit, kernel_uarg, task, 0, "uinit");
    134136       
    135137        /*
  • generic/src/proc/thread.c

    r6c6a19e6 r0f250f9  
    3030#include <proc/thread.h>
    3131#include <proc/task.h>
     32#include <proc/uarg.h>
    3233#include <mm/frame.h>
    3334#include <mm/page.h>
     
    430431 *
    431432 */
    432 __native sys_thread_create(__address function, void *arg, void *stack, char *name)
     433__native sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name)
    433434{
    434435        thread_t *t;
    435436        char namebuf[THREAD_NAME_BUFLEN];
    436         uspace_arg_t *uarg;
     437        uspace_arg_t *kernel_uarg;              /* TODO: store kernel_uarg in thread_t */
    437438        __u32 tid;
    438439
    439         copy_from_uspace(namebuf, name, THREAD_NAME_BUFLEN);
    440         uarg = (uspace_arg_t *) malloc(sizeof(uarg), 0);
    441        
    442         uarg->uspace_entry = function;
    443         uarg->uspace_stack = (__address) stack;
    444 
    445         if ((t = thread_create(uinit, uarg, TASK, 0, namebuf))) {
     440        copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN);
     441
     442        kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);
     443        copy_from_uspace(kernel_uarg, uspace_uarg, sizeof(uspace_arg_t));
     444
     445        if ((t = thread_create(uinit, kernel_uarg, TASK, 0, namebuf))) {
    446446                tid = t->tid;
    447447                thread_ready(t);
    448448                return (__native) tid;
    449449        } else {
    450                 free(namebuf);
     450                free(kernel_uarg);
    451451        }
    452452
     
    457457 *
    458458 */
    459 __native sys_thread_exit(int status)
     459__native sys_thread_exit(int uspace_status)
    460460{
    461461        thread_exit();
Note: See TracChangeset for help on using the changeset viewer.