Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1060 → Rev 1062

/kernel/trunk/test/synch/rwlock2/test.c
74,7 → 74,7
rwlock_read_lock(&rwlock);
rwlock_read_lock(&rwlock);
thrd = thread_create(writer, NULL, TASK, 0);
thrd = thread_create(writer, NULL, TASK, 0, "writer");
if (thrd)
thread_ready(thrd);
else
/kernel/trunk/test/synch/rwlock3/test.c
77,7 → 77,7
rwlock_write_lock(&rwlock);
for (i=0; i<4; i++) {
thrd = thread_create(reader, NULL, TASK, 0);
thrd = thread_create(reader, NULL, TASK, 0, "reader");
if (thrd)
thread_ready(thrd);
else
/kernel/trunk/test/synch/semaphore1/test.c
99,7 → 99,7
for (j=0; j<(CONSUMERS+PRODUCERS)/2; j++) {
for (k=0; k<i; k++) {
thrd = thread_create(consumer, NULL, TASK, 0);
thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
if (thrd)
thread_ready(thrd);
else
106,7 → 106,7
failed();
}
for (k=0; k<(4-i); k++) {
thrd = thread_create(producer, NULL, TASK, 0);
thrd = thread_create(producer, NULL, TASK, 0, "producer");
if (thrd)
thread_ready(thrd);
else
/kernel/trunk/test/synch/rwlock4/test.c
137,7 → 137,7
k = random(7) + 1;
printf("Creating %d readers\n", k);
for (i=0; i<k; i++) {
thrd = thread_create(reader, NULL, TASK, 0);
thrd = thread_create(reader, NULL, TASK, 0, "reader");
if (thrd)
thread_ready(thrd);
else
147,7 → 147,7
k = random(5) + 1;
printf("Creating %d writers\n", k);
for (i=0; i<k; i++) {
thrd = thread_create(writer, NULL, TASK, 0);
thrd = thread_create(writer, NULL, TASK, 0, "writer");
if (thrd)
thread_ready(thrd);
else
/kernel/trunk/test/synch/semaphore2/test.c
107,7 → 107,7
k = random(7) + 1;
printf("Creating %d consumers\n", k);
for (i=0; i<k; i++) {
thrd = thread_create(consumer, NULL, TASK, 0);
thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
if (thrd)
thread_ready(thrd);
else
/kernel/trunk/test/synch/rwlock5/test.c
95,7 → 95,7
for (j=0; j<(READERS+WRITERS)/2; j++) {
for (k=0; k<i; k++) {
thrd = thread_create(reader, NULL, TASK, 0);
thrd = thread_create(reader, NULL, TASK, 0, "reader");
if (thrd)
thread_ready(thrd);
else
102,7 → 102,7
failed();
}
for (k=0; k<(4-i); k++) {
thrd = thread_create(writer, NULL, TASK, 0);
thrd = thread_create(writer, NULL, TASK, 0, "writer");
if (thrd)
thread_ready(thrd);
else
/kernel/trunk/test/thread/thread1/test.c
39,7 → 39,7
 
#define THREADS 5
 
static void thread(void *data)
static void threadtest(void *data)
{
while(1)
{
54,7 → 54,7
int i;
 
for (i=0; i<THREADS; i++) {
if (!(t = thread_create(thread, NULL, TASK, 0)))
if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest")))
panic("could not create thread\n");
thread_ready(t);
}
/kernel/trunk/test/mm/falloc2/test.c
44,12 → 44,12
#define THREAD_RUNS 1
#define THREADS 8
 
static void thread(void * arg);
static void falloc(void * arg);
static void failed(void);
 
static atomic_t thread_count;
 
void thread(void * arg)
void falloc(void * arg)
{
int status, order, run, allocated, i;
__u8 val = THREAD->tid % THREADS;
107,7 → 107,7
for (i = 0; i < THREADS; i++) {
thread_t * thrd;
thrd = thread_create(thread, NULL, TASK, 0);
thrd = thread_create(falloc, NULL, TASK, 0, "falloc");
if (thrd)
thread_ready(thrd);
else
/kernel/trunk/test/mm/slab1/test.c
108,7 → 108,7
slab_cache_t *thr_cache;
semaphore_t thr_sem;
 
static void thread(void *data)
static void slabtest(void *data)
{
int offs = (int)(__native) data;
int i,j;
138,7 → 138,7
SLAB_CACHE_NOMAGAZINE);
semaphore_initialize(&thr_sem,0);
for (i=0; i<THREADS; i++) {
if (!(t = thread_create(thread, (void *)(__native)i, TASK, 0)))
if (!(t = thread_create(slabtest, (void *)(__native)i, TASK, 0, "slabtest")))
panic("could not create thread\n");
thread_ready(t);
}
/kernel/trunk/test/mm/slab2/test.c
122,7 → 122,7
 
#define THREADS 8
 
static void thread(void *priv)
static void slabtest(void *priv)
{
void *data=NULL, *new;
 
188,7 → 188,7
0);
semaphore_initialize(&thr_sem,0);
for (i=0; i<THREADS; i++) {
if (!(t = thread_create(thread, NULL, TASK, 0)))
if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest")))
panic("could not create thread\n");
thread_ready(t);
}
/kernel/trunk/test/fpu/mips1/test.c
112,10 → 112,10
printf("Creating %d threads... ", THREADS);
 
for (i=0; i<THREADS/2; i++) {
if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0)))
if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0, "testit1")))
panic("could not create thread\n");
thread_ready(t);
if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0)))
if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0, "testit2")))
panic("could not create thread\n");
thread_ready(t);
}
/kernel/trunk/test/fpu/fpu1/test.c
143,7 → 143,6
atomic_inc(&threads_ok);
}
 
 
void test(void)
{
thread_t *t;
155,10 → 154,10
printf("Creating %d threads... ", THREADS);
 
for (i=0; i<THREADS/2; i++) {
if (!(t = thread_create(e, NULL, TASK, 0)))
if (!(t = thread_create(e, NULL, TASK, 0, "e")))
panic("could not create thread\n");
thread_ready(t);
if (!(t = thread_create(pi, NULL, TASK, 0)))
if (!(t = thread_create(pi, NULL, TASK, 0, "pi")))
panic("could not create thread\n");
thread_ready(t);
}
172,43 → 171,3
printf("Test passed.\n");
}
 
/*
static void pi(void *data)
{
#undef PI_10e8
#define PI_10e8 3141592
 
 
int i;
double lpi, pi;
double n, ab, ad;
 
 
printf("pi test\n");
 
waitq_sleep(&can_start);
 
 
for (i = 0; i<ATTEMPTS; i++) {
lpi = -1;
pi = 0;
 
for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {
double sc, cd;
 
sc = sqrt(1 - (ab*ab/4));
cd = 1 - sc;
ad = sqrt(ab*ab/4 + cd*cd);
lpi = pi;
pi = 2 * n * ad;
}
 
atomic_inc(&threads_ok);
if((int)(1000000*pi)!=PI_10e8)
panic("tid%d: pi*10e6=%d\n", THREAD->tid, (int) 1000000*pi);
}
 
printf("tid%d: pi*10e6=%d\n", THREAD->tid, (int) 1000000*pi);
}
*/
/kernel/trunk/test/fpu/sse1/test.c
112,10 → 112,10
printf("Creating %d threads... ", THREADS);
 
for (i=0; i<THREADS/2; i++) {
if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0)))
if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0, "testit1")))
panic("could not create thread\n");
thread_ready(t);
if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0)))
if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0, "testit2")))
panic("could not create thread\n");
thread_ready(t);
}
/kernel/trunk/generic/include/proc/task.h
37,6 → 37,7
/** Task structure. */
struct task {
SPINLOCK_DECLARE(lock);
char *name;
link_t th_head; /**< List of threads contained in this task. */
link_t tasks_link; /**< Link to other tasks within the system. */
as_t *as; /**< Address space. */
52,7 → 53,7
extern link_t tasks_head;
 
extern void task_init(void);
extern task_t *task_create(as_t *as);
extern task_t *task_run_program(void * program_addr);
extern task_t *task_create(as_t *as, char *name);
extern task_t *task_run_program(void *program_addr, char *name);
 
#endif
/kernel/trunk/generic/include/proc/thread.h
59,7 → 59,10
#define X_WIRED (1<<0)
#define X_STOLEN (1<<1)
 
/** Thread structure. There is one per thread. */
struct thread {
char *name;
link_t rq_link; /**< Run queue link. */
link_t wq_link; /**< Wait queue link. */
link_t th_link; /**< Links to threads within containing task. */
125,7 → 128,7
extern link_t threads_head; /**< List of all threads in the system. */
 
extern void thread_init(void);
extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags);
extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name);
extern void thread_ready(thread_t *t);
extern void thread_exit(void);
 
/kernel/trunk/generic/src/proc/scheduler.c
617,7 → 617,6
/* We are going to mess with scheduler structures,
* let's not be interrupted */
ipl = interrupts_disable();
printf("Scheduler dump:\n");
for (cpu=0;cpu < config.cpu_count; cpu++) {
 
if (!cpus[cpu].active)
624,8 → 623,8
continue;
 
spinlock_lock(&cpus[cpu].lock);
printf("cpu%d: nrdy: %d, needs_relink: %d\n",
cpus[cpu].id, atomic_get(&cpus[cpu].nrdy), cpus[cpu].needs_relink);
printf("cpu%d: address=%P, nrdy=%d, needs_relink=%d\n",
cpus[cpu].id, &cpus[cpu], atomic_get(&cpus[cpu].nrdy), cpus[cpu].needs_relink);
for (i=0; i<RQ_COUNT; i++) {
r = &cpus[cpu].rq[i];
/kernel/trunk/generic/src/proc/task.c
62,11 → 62,12
* Create new task with no threads.
*
* @param as Task's address space.
* @param name Symbolic name.
*
* @return New task's structure
*
*/
task_t *task_create(as_t *as)
task_t *task_create(as_t *as, char *name)
{
ipl_t ipl;
task_t *ta;
78,6 → 79,7
list_initialize(&ta->th_head);
list_initialize(&ta->tasks_link);
ta->as = as;
ta->name = name;
 
ipc_answerbox_init(&ta->answerbox);
101,9 → 103,12
 
/** Create new task with 1 thread and run it
*
* @param programe_addr Address of program executable image.
* @param name Program name.
*
* @return Task of the running program or NULL on error
*/
task_t * task_run_program(void *program_addr)
task_t * task_run_program(void *program_addr, char *name)
{
as_t *as;
as_area_t *a;
119,9 → 124,9
return NULL;
}
task = task_create(as);
task = task_create(as, name);
t = thread_create(uinit, (void *)((elf_header_t *)program_addr)->e_entry,
task, THREAD_USER_STACK);
task, 0, "uinit");
/*
* Create the data as_area.
148,8 → 153,8
for (cur=tasks_head.next; cur!=&tasks_head; cur=cur->next) {
t = list_get_instance(cur, task_t, tasks_link);
spinlock_lock(&t->lock);
printf("Task: %Q ActiveCalls: %d", t->taskid,
atomic_get(&t->active_calls));
printf("%s: address=%P, taskid=%Q, as=%P, ActiveCalls: %d",
t->name, t, t->taskid, t->as, atomic_get(&t->active_calls));
for (i=0; i < IPC_MAX_PHONES; i++) {
if (t->phones[i].callee)
printf(" Ph(%d): %P ", i,t->phones[i].callee);
/kernel/trunk/generic/src/proc/thread.c
248,11 → 248,12
* @param arg Thread's implementing function argument.
* @param task Task to which the thread belongs.
* @param flags Thread flags.
* @param name Symbolic name.
*
* @return New thread's structure on success, NULL on failure.
*
*/
thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags)
thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name)
{
thread_t *t;
ipl_t ipl;
279,6 → 280,7
t->saved_context.ipl = interrupts_read();
interrupts_restore(ipl);
t->name = name;
t->thread_code = func;
t->thread_arg = arg;
t->ticks = -1;
409,9 → 411,12
 
for (cur=threads_head.next; cur!=&threads_head; cur=cur->next) {
t = list_get_instance(cur, thread_t, threads_link);
printf("Thr: %d(%s) ", t->tid, thread_states[t->state]);
printf("%s: address=%P, tid=%d, state=%s, task=%P, code=%P, stack=%P, cpu=",
t->name, t, t->tid, thread_states[t->state], t->task, t->thread_code, t->kstack);
if (t->cpu)
printf("cpu%d ", t->cpu->id);
else
printf("none");
printf("\n");
}
 
/kernel/trunk/generic/src/main/kinit.c
80,7 → 80,7
* not mess together with kcpulb threads.
* Just a beautification.
*/
if ((t = thread_create(kmp, NULL, TASK, 0))) {
if ((t = thread_create(kmp, NULL, TASK, 0, "kmp"))) {
spinlock_lock(&t->lock);
t->flags |= X_WIRED;
t->cpu = &cpus[0];
105,7 → 105,7
*/
for (i = 0; i < config.cpu_count; i++) {
 
if ((t = thread_create(kcpulb, NULL, TASK, 0))) {
if ((t = thread_create(kcpulb, NULL, TASK, 0, "kcpulb"))) {
spinlock_lock(&t->lock);
t->flags |= X_WIRED;
t->cpu = &cpus[i];
126,7 → 126,7
/*
* Create kernel console.
*/
if ((t = thread_create(kconsole, "kconsole", TASK, 0)))
if ((t = thread_create(kconsole, "kconsole", TASK, 0, "kconsole")))
thread_ready(t);
else
panic("thread_create/kconsole\n");
142,7 → 142,7
if (init.tasks[i].addr % FRAME_SIZE)
panic("init[%d].addr is not frame aligned", i);
 
utask = task_run_program((void *) init.tasks[i].addr);
utask = task_run_program((void *) init.tasks[i].addr, "USPACE");
if (utask) {
if (!ipc_phone_0)
ipc_phone_0 = &utask->answerbox;
/kernel/trunk/generic/src/main/main.c
196,7 → 196,7
/*
* Create kernel task.
*/
k = task_create(AS_KERNEL);
k = task_create(AS_KERNEL, "KERNEL");
if (!k)
panic("can't create kernel task\n");
203,7 → 203,7
/*
* Create the first thread.
*/
t = thread_create(kinit, NULL, k, 0);
t = thread_create(kinit, NULL, k, 0, "kinit");
if (!t)
panic("can't create kinit thread\n");
thread_ready(t);
/kernel/trunk/arch/sparc64/src/sparc64.c
57,7 → 57,7
/*
* Create thread that reads characters from OFW's input.
*/
t = thread_create(kofwinput, NULL, TASK, 0);
t = thread_create(kofwinput, NULL, TASK, 0, "kofwinput");
if (!t)
panic("cannot create kofwinput\n");
thread_ready(t);
65,7 → 65,7
/*
* Create thread that polls keyboard.
*/
t = thread_create(kkbdpoll, NULL, TASK, 0);
t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll");
if (!t)
panic("cannot create kkbdpoll\n");
thread_ready(t);