Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2211 → Rev 2216

/trunk/kernel/test/synch/rwlock3.c
45,14 → 45,14
thread_detach(THREAD);
if (!sh_quiet)
printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu: trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);
rwlock_read_lock(&rwlock);
rwlock_read_unlock(&rwlock);
if (!sh_quiet) {
printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu: success\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu: trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);
}
 
rwlock_write_lock(&rwlock);
59,7 → 59,7
rwlock_write_unlock(&rwlock);
if (!sh_quiet)
printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu: success\n", CPU->id, THREAD->tid);
atomic_dec(&thread_count);
}
/trunk/kernel/test/synch/rwlock4.c
74,18 → 74,18
to = random(40000);
if (!sh_quiet)
printf("cpu%d, tid %d w+ (%d)\n", CPU->id, THREAD->tid, to);
printf("cpu%d, tid %llu w+ (%d)\n", CPU->id, THREAD->tid, to);
rc = rwlock_write_lock_timeout(&rwlock, to);
if (SYNCH_FAILED(rc)) {
if (!sh_quiet)
printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu w!\n", CPU->id, THREAD->tid);
atomic_dec(&thread_count);
return;
}
if (!sh_quiet)
printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu w=\n", CPU->id, THREAD->tid);
 
if (rwlock.readers_in) {
if (!sh_quiet)
106,7 → 106,7
rwlock_write_unlock(&rwlock);
if (!sh_quiet)
printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu w-\n", CPU->id, THREAD->tid);
atomic_dec(&thread_count);
}
 
119,24 → 119,24
to = random(2000);
if (!sh_quiet)
printf("cpu%d, tid %d r+ (%d)\n", CPU->id, THREAD->tid, to);
printf("cpu%d, tid %llu r+ (%d)\n", CPU->id, THREAD->tid, to);
rc = rwlock_read_lock_timeout(&rwlock, to);
if (SYNCH_FAILED(rc)) {
if (!sh_quiet)
printf("cpu%d, tid %d r!\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu r!\n", CPU->id, THREAD->tid);
atomic_dec(&thread_count);
return;
}
if (!sh_quiet)
printf("cpu%d, tid %d r=\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu r=\n", CPU->id, THREAD->tid);
thread_usleep(30000);
rwlock_read_unlock(&rwlock);
if (!sh_quiet)
printf("cpu%d, tid %d r-\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu r-\n", CPU->id, THREAD->tid);
atomic_dec(&thread_count);
}
 
/trunk/kernel/test/synch/semaphore2.c
67,18 → 67,18
waitq_sleep(&can_start);
to = random(20000);
printf("cpu%d, tid %d down+ (%d)\n", CPU->id, THREAD->tid, to);
printf("cpu%d, tid %llu down+ (%d)\n", CPU->id, THREAD->tid, to);
rc = semaphore_down_timeout(&sem, to);
if (SYNCH_FAILED(rc)) {
printf("cpu%d, tid %d down!\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu down!\n", CPU->id, THREAD->tid);
return;
}
printf("cpu%d, tid %d down=\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu down=\n", CPU->id, THREAD->tid);
thread_usleep(random(30000));
semaphore_up(&sem);
printf("cpu%d, tid %d up\n", CPU->id, THREAD->tid);
printf("cpu%d, tid %llu up\n", CPU->id, THREAD->tid);
}
 
char * test_semaphore2(bool quiet)
/trunk/kernel/test/thread/thread1.c
48,7 → 48,7
 
while (atomic_get(&finish)) {
if (!sh_quiet)
printf("%d ", (int) (THREAD->tid));
printf("%llu ", THREAD->tid);
thread_usleep(100000);
}
atomic_inc(&threads_finished);
/trunk/kernel/test/mm/falloc2.c
58,7 → 58,7
uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC);
if (frames == NULL) {
if (!sh_quiet)
printf("Thread #%d (cpu%d): Unable to allocate frames\n", THREAD->tid, CPU->id);
printf("Thread #%llu (cpu%d): Unable to allocate frames\n", THREAD->tid, CPU->id);
atomic_inc(&thread_fail);
atomic_dec(&thread_count);
return;
69,7 → 69,7
for (run = 0; run < THREAD_RUNS; run++) {
for (order = 0; order <= MAX_ORDER; order++) {
if (!sh_quiet)
printf("Thread #%d (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
printf("Thread #%llu (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
allocated = 0;
for (i = 0; i < (MAX_FRAMES >> order); i++) {
82,16 → 82,16
}
if (!sh_quiet)
printf("Thread #%d (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
printf("Thread #%llu (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
if (!sh_quiet)
printf("Thread #%d (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id);
printf("Thread #%llu (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id);
for (i = 0; i < allocated; i++) {
for (k = 0; k <= ((FRAME_SIZE << order) - 1); k++) {
if (((uint8_t *) frames[i])[k] != val) {
if (!sh_quiet)
printf("Thread #%d (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
printf("Thread #%llu (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
atomic_inc(&thread_fail);
goto cleanup;
}
100,7 → 100,7
}
if (!sh_quiet)
printf("Thread #%d (cpu%d): Finished run.\n", THREAD->tid, CPU->id);
printf("Thread #%llu (cpu%d): Finished run.\n", THREAD->tid, CPU->id);
}
}
 
108,7 → 108,7
free(frames);
if (!sh_quiet)
printf("Thread #%d (cpu%d): Exiting\n", THREAD->tid, CPU->id);
printf("Thread #%llu (cpu%d): Exiting\n", THREAD->tid, CPU->id);
atomic_dec(&thread_count);
}
 
/trunk/kernel/test/mm/slab1.c
137,7 → 137,7
thread_detach(THREAD);
if (!sh_quiet)
printf("Starting thread #%d...\n", THREAD->tid);
printf("Starting thread #%llu...\n", THREAD->tid);
for (j = 0; j < 10; j++) {
for (i = 0; i < THR_MEM_COUNT; i++)
151,7 → 151,7
}
if (!sh_quiet)
printf("Thread #%d finished\n", THREAD->tid);
printf("Thread #%llu finished\n", THREAD->tid);
semaphore_up(&thr_sem);
}
/trunk/kernel/test/mm/slab2.c
150,11 → 150,11
mutex_unlock(&starter_mutex);
if (!sh_quiet)
printf("Starting thread #%d...\n",THREAD->tid);
printf("Starting thread #%llu...\n",THREAD->tid);
 
/* Alloc all */
if (!sh_quiet)
printf("Thread #%d allocating...\n", THREAD->tid);
printf("Thread #%llu allocating...\n", THREAD->tid);
while (1) {
/* Call with atomic to detect end of memory */
166,7 → 166,7
}
if (!sh_quiet)
printf("Thread #%d releasing...\n", THREAD->tid);
printf("Thread #%llu releasing...\n", THREAD->tid);
while (data) {
new = *((void **)data);
176,7 → 176,7
}
if (!sh_quiet)
printf("Thread #%d allocating...\n", THREAD->tid);
printf("Thread #%llu allocating...\n", THREAD->tid);
while (1) {
/* Call with atomic to detect end of memory */
188,7 → 188,7
}
if (!sh_quiet)
printf("Thread #%d releasing...\n", THREAD->tid);
printf("Thread #%llu releasing...\n", THREAD->tid);
while (data) {
new = *((void **)data);
198,7 → 198,7
}
if (!sh_quiet)
printf("Thread #%d finished\n", THREAD->tid);
printf("Thread #%llu finished\n", THREAD->tid);
slab_print_list();
semaphore_up(&thr_sem);
/trunk/kernel/test/fpu/mips2.c
72,7 → 72,7
if (arg != after_arg) {
if (!sh_quiet)
printf("General reg tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
printf("General reg tid%llu: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
atomic_inc(&threads_fault);
break;
}
104,7 → 104,7
if (arg != after_arg) {
if (!sh_quiet)
printf("General reg tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
printf("General reg tid%llu: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
atomic_inc(&threads_fault);
break;
}
/trunk/kernel/test/fpu/fpu1.c
126,7 → 126,7
 
if ((int) (100000000 * e) != E_10e8) {
if (!sh_quiet)
printf("tid%d: e*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
printf("tid%llu: e*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
atomic_inc(&threads_fault);
break;
}
161,7 → 161,7
#ifdef KERN_ia64_ARCH_H_
if ((int) (1000000 * pi) != PI_10e8) {
if (!sh_quiet)
printf("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100));
printf("tid%llu: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100));
atomic_inc(&threads_fault);
break;
}
168,7 → 168,7
#else
if ((int) (100000000 * pi) != PI_10e8) {
if (!sh_quiet)
printf("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
printf("tid%llu: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
atomic_inc(&threads_fault);
break;
}
/trunk/kernel/test/fpu/sse1.c
72,7 → 72,7
if (arg != after_arg) {
if (!sh_quiet)
printf("tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
printf("tid%llu: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
atomic_inc(&threads_fault);
break;
}
104,7 → 104,7
if (arg != after_arg) {
if (!sh_quiet)
printf("tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
printf("tid%llu: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
atomic_inc(&threads_fault);
break;
}
/trunk/kernel/generic/include/proc/task.h
90,10 → 90,10
* Active asynchronous messages. It is used for limiting uspace to
* certain extent.
*/
atomic_t active_calls;
atomic_t active_calls;
/** Architecture specific task data. */
task_arch_t arch;
task_arch_t arch;
/**
* Serializes access to the B+tree of task's futexes. This mutex is
/trunk/kernel/generic/include/proc/thread.h
193,7 → 193,7
/** Thread's priority. Implemented as index to CPU->rq */
int priority;
/** Thread ID. */
uint32_t tid;
thread_id_t tid;
/** Architecture-specific data. */
thread_arch_t arch;
248,9 → 248,9
extern slab_cache_t *fpu_context_slab;
 
/* Thread syscall prototypes. */
unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name);
unative_t sys_thread_exit(int uspace_status);
unative_t sys_thread_get_id(void);
extern unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name, thread_id_t *uspace_thread_id);
extern unative_t sys_thread_exit(int uspace_status);
extern unative_t sys_thread_get_id(thread_id_t *uspace_thread_id);
 
#endif
 
/trunk/kernel/generic/include/interrupt.h
48,7 → 48,7
#define fault_if_from_uspace(istate, cmd, ...) \
{ \
if (istate_from_uspace(istate)) { \
klog_printf("Task %lld killed due to an exception at %p.", TASK->taskid, istate_get_pc(istate)); \
klog_printf("Task %llu killed due to an exception at %p.", TASK->taskid, istate_get_pc(istate)); \
klog_printf(" " cmd, ##__VA_ARGS__); \
task_kill(TASK->taskid); \
thread_exit(); \
/trunk/kernel/generic/src/console/cmd.c
713,7 → 713,7
/** Write 4 byte value to address */
int cmd_set4(cmd_arg_t *argv)
{
uint32_t *addr ;
uint32_t *addr;
uint32_t arg1 = argv[1].intval;
bool pointer = false;
 
/trunk/kernel/generic/src/proc/scheduler.c
450,7 → 450,7
/*
* Entering state is unexpected.
*/
panic("tid%d: unexpected state %s\n", THREAD->tid,
panic("tid%llu: unexpected state %s\n", THREAD->tid,
thread_states[THREAD->state]);
break;
}
503,7 → 503,7
THREAD->state = Running;
 
#ifdef SCHEDULER_VERBOSE
printf("cpu%d: tid %d (priority=%d, ticks=%lld, nrdy=%ld)\n",
printf("cpu%d: tid %llu (priority=%d, ticks=%llu, nrdy=%ld)\n",
CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks,
atomic_get(&CPU->nrdy));
#endif
639,7 → 639,7
*/
spinlock_lock(&t->lock);
#ifdef KCPULB_VERBOSE
printf("kcpulb%d: TID %d -> cpu%d, nrdy=%ld, "
printf("kcpulb%d: TID %llu -> cpu%d, nrdy=%ld, "
"avg=%nd\n", CPU->id, t->tid, CPU->id,
atomic_get(&CPU->nrdy),
atomic_get(&nrdy) / config.cpu_active);
722,7 → 722,7
for (cur = r->rq_head.next; cur != &r->rq_head;
cur = cur->next) {
t = list_get_instance(cur, thread_t, rq_link);
printf("%d(%s) ", t->tid,
printf("%llu(%s) ", t->tid,
thread_states[t->state]);
}
printf("\n");
/trunk/kernel/generic/src/proc/task.c
399,7 → 399,7
char suffix;
order(task_get_accounting(t), &cycles, &suffix);
printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd "
printf("%-6llu %-10s %-3ld %#10zx %#10zx %9llu%c %7zd "
"%6zd", t->taskid, t->name, t->context, t, t->as,
cycles, suffix, t->refcount,
atomic_get(&t->active_calls));
486,7 → 486,7
 
ipc_cleanup();
futex_cleanup();
klog_printf("Cleanup of task %lld completed.", TASK->taskid);
klog_printf("Cleanup of task %llu completed.", TASK->taskid);
}
 
/** Kernel thread used to kill the userspace task when its main thread exits.
/trunk/kernel/generic/src/proc/thread.c
94,7 → 94,7
btree_t threads_btree;
 
SPINLOCK_INITIALIZE(tidlock);
uint32_t last_tid = 0;
thread_id_t last_tid = 0;
 
static slab_cache_t *thread_slab;
#ifdef ARCH_HAS_FPU
580,7 → 580,7
char suffix;
order(t->cycles, &cycles, &suffix);
printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx "
printf("%-6llu %-10s %#10zx %-8s %#10zx %-3ld %#10zx "
"%#10zx %9llu%c ", t->tid, t->name, t,
thread_states[t->state], t->task, t->task->context,
t->thread_code, t->kstack, cycles, suffix);
636,12 → 636,11
/** Process syscall to create new thread.
*
*/
unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name)
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];
uspace_arg_t *kernel_uarg;
uint32_t tid;
int rc;
 
rc = copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN);
658,12 → 657,14
t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf,
false);
if (t) {
tid = t->tid;
thread_ready(t);
return (unative_t) tid;
} else {
if (uspace_thread_id != NULL)
return (unative_t) copy_to_uspace(uspace_thread_id, &t->tid,
sizeof(t->tid));
else
return 0;
} else
free(kernel_uarg);
}
 
return (unative_t) ENOMEM;
}
680,15 → 681,19
 
/** Syscall for getting TID.
*
* @return Thread ID.
* @param uspace_thread_id Userspace address of 8-byte buffer where to store
* current thread ID.
*
* @return 0 on success or an error code from @ref errno.h.
*/
unative_t sys_thread_get_id(void)
unative_t sys_thread_get_id(thread_id_t *uspace_thread_id)
{
/*
* No need to acquire lock on THREAD because tid
* remains constant for the lifespan of the thread.
*/
return THREAD->tid;
return (unative_t) copy_to_uspace(uspace_thread_id, &THREAD->tid,
sizeof(THREAD->tid));
}
 
/** @}
/trunk/kernel/generic/src/adt/btree.c
970,7 → 970,7
 
printf("(");
for (i = 0; i < node->keys; i++) {
printf("%lld%s", node->key[i], i < node->keys - 1 ? "," : "");
printf("%llu%s", node->key[i], i < node->keys - 1 ? "," : "");
if (node->depth && node->subtree[i]) {
list_append(&node->subtree[i]->bfs_link, &head);
}
992,7 → 992,7
 
printf("(");
for (i = 0; i < node->keys; i++)
printf("%lld%s", node->key[i], i < node->keys - 1 ? "," : "");
printf("%llu%s", node->key[i], i < node->keys - 1 ? "," : "");
printf(")");
}
printf("\n");
/trunk/kernel/generic/src/syscall/syscall.c
100,7 → 100,7
if (id < SYSCALL_END)
rc = syscall_table[id](a1, a2, a3, a4);
else {
klog_printf("TASK %lld: Unknown syscall id %d",TASK->taskid,id);
klog_printf("TASK %llu: Unknown syscall id %d",TASK->taskid,id);
task_kill(TASK->taskid);
thread_exit();
}
/trunk/kernel/generic/src/ipc/ipc.c
502,7 → 502,7
printf("ABOX - CALLS:\n");
for (tmp=task->answerbox.calls.next; tmp != &task->answerbox.calls;tmp = tmp->next) {
call = list_get_instance(tmp, call_t, link);
printf("Callid: %p Srctask:%lld M:%d A1:%d A2:%d A3:%d Flags:%x\n",call,
printf("Callid: %p Srctask:%llu M:%d A1:%d A2:%d A3:%d Flags:%x\n",call,
call->sender->taskid, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), call->flags);
}
512,7 → 512,7
tmp != &task->answerbox.dispatched_calls;
tmp = tmp->next) {
call = list_get_instance(tmp, call_t, link);
printf("Callid: %p Srctask:%lld M:%d A1:%d A2:%d A3:%d Flags:%x\n",call,
printf("Callid: %p Srctask:%llu M:%d A1:%d A2:%d A3:%d Flags:%x\n",call,
call->sender->taskid, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), call->flags);
}
/trunk/kernel/arch/sparc64/include/types.h
62,6 → 62,7
typedef int64_t native_t;
 
typedef uint8_t bool;
typedef uint64_t thread_id_t;
typedef uint64_t task_id_t;
typedef uint32_t context_id_t;
 
/trunk/kernel/arch/ia64/include/types.h
70,6 → 70,7
typedef int64_t native_t;
 
typedef uint8_t bool;
typedef uint64_t thread_id_t;
typedef uint64_t task_id_t;
typedef uint32_t context_id_t;
 
/trunk/kernel/arch/arm32/include/types.h
62,6 → 62,7
typedef int32_t native_t;
 
typedef uint8_t bool;
typedef uint64_t thread_id_t;
typedef uint64_t task_id_t;
typedef uint32_t context_id_t;
 
/trunk/kernel/arch/ppc32/include/types.h
62,6 → 62,7
typedef int32_t native_t;
 
typedef uint8_t bool;
typedef uint64_t thread_id_t;
typedef uint64_t task_id_t;
typedef uint32_t context_id_t;
 
/trunk/kernel/arch/ia32xen/include/types.h
62,6 → 62,7
typedef int32_t native_t;
 
typedef uint8_t bool;
typedef uint64_t thread_id_t;
typedef uint64_t task_id_t;
typedef uint32_t context_id_t;
 
/trunk/kernel/arch/amd64/include/types.h
62,6 → 62,7
typedef int64_t native_t;
 
typedef uint8_t bool;
typedef uint64_t thread_id_t;
typedef uint64_t task_id_t;
typedef uint32_t context_id_t;
 
/trunk/kernel/arch/ppc64/include/types.h
62,6 → 62,7
typedef int64_t native_t;
 
typedef uint8_t bool;
typedef uint64_t thread_id_t;
typedef uint64_t task_id_t;
typedef uint32_t context_id_t;
 
/trunk/kernel/arch/mips32/include/types.h
62,6 → 62,7
typedef int32_t native_t;
 
typedef uint8_t bool;
typedef uint64_t thread_id_t;
typedef uint64_t task_id_t;
typedef uint32_t context_id_t;
 
/trunk/kernel/arch/ia32/include/types.h
62,6 → 62,7
typedef int32_t native_t;
 
typedef uint8_t bool;
typedef uint64_t thread_id_t;
typedef uint64_t task_id_t;
typedef uint32_t context_id_t;
 
/trunk/uspace/tester/thread/thread1.c
45,7 → 45,7
 
while (atomic_get(&finish)) {
if (!sh_quiet)
printf("%d ", thread_get_id());
printf("%llu ", thread_get_id());
usleep(100000);
}
atomic_inc(&threads_finished);
60,8 → 60,7
atomic_set(&threads_finished, 0);
 
for (i = 0; i < THREADS; i++) {
int t;
if ((t = thread_create(threadtest, NULL, "threadtest")) < 0) {
if (thread_create(threadtest, NULL, "threadtest", NULL) < 0) {
if (!quiet)
printf("Could not create thread %d\n", i);
break;
/trunk/uspace/libc/include/thread.h
39,14 → 39,16
#include <libarch/thread.h>
#include <types.h>
 
typedef uint64_t thread_id_t;
 
extern void __thread_entry(void);
extern void __thread_main(uspace_arg_t *uarg);
 
extern int thread_create(void (* function)(void *arg), void *arg, char *name);
extern int thread_create(void (* function)(void *), void *arg, char *name, thread_id_t *tid);
extern void thread_exit(int status);
extern void thread_detach(int thread);
extern int thread_join(int thread);
extern int thread_get_id(void);
extern void thread_detach(thread_id_t thread);
extern int thread_join(thread_id_t thread);
extern thread_id_t thread_get_id(void);
extern tcb_t * __make_tls(void);
extern tcb_t * __alloc_tls(void **data, size_t size);
extern void __free_tls(tcb_t *);
/trunk/uspace/libc/generic/thread.c
124,10 → 124,11
* @param function Function implementing the thread.
* @param arg Argument to be passed to thread.
* @param name Symbolic name of the thread.
* @param tid Thread ID of the newly created thread.
*
* @return TID of the new thread on success or -1 on failure.
* @return Zero on success or a code from @ref errno.h on failure.
*/
int thread_create(void (* function)(void *), void *arg, char *name)
int thread_create(void (* function)(void *), void *arg, char *name, thread_id_t *tid)
{
char *stack;
uspace_arg_t *uarg;
148,7 → 149,7
uarg->uspace_thread_arg = arg;
uarg->uspace_uarg = uarg;
return __SYSCALL2(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name);
return __SYSCALL3(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name, (sysarg_t) tid);
}
 
/** Terminate current thread.
166,7 → 167,7
*
* @param thread TID.
*/
void thread_detach(int thread)
void thread_detach(thread_id_t thread)
{
}
 
178,7 → 179,7
*
* @return Thread exit status.
*/
int thread_join(int thread)
int thread_join(thread_id_t thread)
{
}
 
186,9 → 187,13
*
* @return Current thread ID.
*/
int thread_get_id(void)
thread_id_t thread_get_id(void)
{
return __SYSCALL0(SYS_THREAD_GET_ID);
thread_id_t thread_id;
 
(void) __SYSCALL1(SYS_THREAD_GET_ID, (sysarg_t) &thread_id);
 
return thread_id;
}
 
/** @}