/trunk/kernel/generic/src/proc/thread.c |
---|
299,15 → 299,6 |
if (destroy_task) |
task_destroy(t->task); |
/* |
* If the thread had a userspace context, free up its kernel_uarg |
* structure. |
*/ |
if (t->flags & THREAD_FLAG_USPACE) { |
ASSERT(t->thread_arg); |
free(t->thread_arg); |
} |
slab_free(thread_slab, t); |
} |
321,13 → 312,13 |
* @param flags Thread flags. |
* @param name Symbolic name. |
* @param uncounted Thread's accounting doesn't affect accumulated task |
* accounting. |
* accounting. |
* |
* @return New thread's structure on success, NULL on failure. |
* |
*/ |
thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, |
int flags, char *name, bool uncounted) |
int flags, char *name, bool uncounted) |
{ |
thread_t *t; |
ipl_t ipl; |
646,8 → 637,7 |
/** Process syscall to create new thread. |
* |
*/ |
unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name, |
thread_id_t *uspace_thread_id) |
unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name, thread_id_t *uspace_thread_id) |
{ |
thread_t *t; |
char namebuf[THREAD_NAME_BUFLEN]; |
670,8 → 660,8 |
if (t) { |
thread_ready(t); |
if (uspace_thread_id != NULL) |
return (unative_t) copy_to_uspace(uspace_thread_id, |
&t->tid, sizeof(t->tid)); |
return (unative_t) copy_to_uspace(uspace_thread_id, &t->tid, |
sizeof(t->tid)); |
else |
return 0; |
} else |
/trunk/kernel/generic/src/proc/task.c |
---|
107,12 → 107,9 |
t = NULL; |
link_t *cur; |
for (cur = tasks_btree.leaf_head.next; |
cur != &tasks_btree.leaf_head; cur = cur->next) { |
btree_node_t *node; |
for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) { |
btree_node_t *node = list_get_instance(cur, btree_node_t, leaf_link); |
node = list_get_instance(cur, btree_node_t, leaf_link); |
unsigned int i; |
for (i = 0; i < node->keys; i++) { |
if ((task_t *) node->value[i] != TASK) { |
224,7 → 221,7 |
* |
* @return Task of the running program or NULL on error. |
*/ |
task_t *task_run_program(void *program_addr, char *name) |
task_t * task_run_program(void *program_addr, char *name) |
{ |
as_t *as; |
as_area_t *a; |
/trunk/uspace/libc/generic/thread.c |
---|
77,8 → 77,8 |
/* |
* Zero out the thread local uninitialized data. |
*/ |
memset(data + (&_tbss_start - &_tdata_start), 0, |
&_tbss_end - &_tbss_start); |
memset(data + (&_tbss_start - &_tdata_start), 0, &_tbss_end - |
&_tbss_start); |
return tcb; |
} |
128,12 → 128,10 |
* |
* @return Zero on success or a code from @ref errno.h on failure. |
*/ |
int thread_create(void (* function)(void *), void *arg, char *name, |
thread_id_t *tid) |
int thread_create(void (* function)(void *), void *arg, char *name, thread_id_t *tid) |
{ |
char *stack; |
uspace_arg_t *uarg; |
int rc; |
stack = (char *) malloc(getpagesize() * THREAD_INITIAL_STACK_PAGES_NO); |
if (!stack) |
151,19 → 149,7 |
uarg->uspace_thread_arg = arg; |
uarg->uspace_uarg = uarg; |
rc = __SYSCALL3(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name, |
(sysarg_t) tid); |
if (!rc) { |
/* |
* Failed to create a new thread. |
* Free up the allocated structures. |
*/ |
free(uarg); |
free(stack); |
} |
return rc; |
return __SYSCALL3(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name, (sysarg_t) tid); |
} |
/** Terminate current thread. |