From 9efaa3bbb646150807bb49973e87e4cd8b826073 Mon Sep 17 00:00:00 2001 From: Stephan Zeisberg Date: Tue, 30 Nov 2010 11:37:44 +0100 Subject: [PATCH] branch merge fixes --- core/Jamfile | 6 +--- core/kernel_init.c | 16 ----------- core/msg.c | 27 ----------------- core/mutex.c | 72 +--------------------------------------------- core/sched.c | 17 ----------- core/thread.c | 14 --------- 6 files changed, 2 insertions(+), 150 deletions(-) diff --git a/core/Jamfile b/core/Jamfile index bd92e8221e..89b302c3ff 100644 --- a/core/Jamfile +++ b/core/Jamfile @@ -28,11 +28,7 @@ SubDir TOP core ; Module core : kernel_init.c sched.c mutex.c msg.c queue.c -<<<<<<< HEAD - clist.c thread.c bitarithm.c ; -======= - clist.c thread.c bitarithm.c cib.c ; ->>>>>>> master + clist.c thread.c bitarithm.c cib.c ; Module hwtimer : hwtimer.c : hwtimer_cpu ; diff --git a/core/kernel_init.c b/core/kernel_init.c index 6296e59a24..b38d5a9662 100644 --- a/core/kernel_init.c +++ b/core/kernel_init.c @@ -17,17 +17,6 @@ #include #include #include -<<<<<<< HEAD -#include "tcb.h" -#include "kernel.h" -#include "kernel_intern.h" -#include "sched.h" -#include "flags.h" -#include "cpu.h" -#include "lpm.h" -#include "thread.h" -#include "hwtimer.h" -======= #include #include #include @@ -37,7 +26,6 @@ #include #include #include ->>>>>>> master #ifdef MODULE_AUTO_INIT #include @@ -85,11 +73,7 @@ void kernel_init(void) sched_init(); -<<<<<<< HEAD - if (thread_create(KERNEL_CONF_STACKSIZE_IDLE, PRIORITY_IDLE, CREATE_WOUT_YIELD | CREATE_STACKTEST, idle_thread, idle_name) < 0) { -======= if (thread_create(idle_stack, sizeof(idle_stack), PRIORITY_IDLE, CREATE_WOUT_YIELD | CREATE_STACKTEST, idle_thread, idle_name) < 0) { ->>>>>>> master printf("kernel_init(): error creating idle task.\n"); } diff --git a/core/msg.c b/core/msg.c index e93b6a3c98..b33eda5691 100644 --- a/core/msg.c +++ b/core/msg.c @@ -43,17 +43,8 @@ int msg_send(msg* m, unsigned int target_pid, bool block) { return msg_send_int(m, target_pid); } -<<<<<<< HEAD - int result = 1; - tcb *target = (tcb*)sched_threads[target_pid]; - m->sender_pid = thread_pid; - if (m->sender_pid == target_pid) return -1; -======= - tcb *target = (tcb*)sched_threads[target_pid]; ->>>>>>> master - m->sender_pid = thread_pid; if (m->sender_pid == target_pid) { return -1; @@ -80,11 +71,7 @@ int msg_send(msg* m, unsigned int target_pid, bool block) { queue_node_t n; n.priority = active_thread->priority; n.data = (unsigned int) active_thread; -<<<<<<< HEAD - DEBUG("%s: Adding node to msg_queue:\n", active_thread->name); -======= DEBUG("%s: Adding node to msg_waiters:\n", active_thread->name); ->>>>>>> master queue_priority_add(&(target->msg_waiters), &n); @@ -199,14 +186,6 @@ int msg_receive(msg* m) { me->wait_data = (void*) m; } -<<<<<<< HEAD - if (n == NULL) { - DEBUG("%s: msg_receive blocked\n", active_thread->name); - sched_set_status(me, STATUS_RECEIVE_BLOCKED); - - eINT(); - thread_yield(); -======= queue_node_t *node = queue_remove_head(&(me->msg_waiters)); if (node == NULL) { @@ -214,7 +193,6 @@ int msg_receive(msg* m) { if (n < 0) { DEBUG("%s: msg_receive(): No msg in queue. Going blocked.\n", active_thread->name); sched_set_status(me, STATUS_RECEIVE_BLOCKED); ->>>>>>> master eINT(); thread_yield(); @@ -223,10 +201,6 @@ int msg_receive(msg* m) { } return 1; } else { -<<<<<<< HEAD - DEBUG("%s: msg_receive direct copy.\n", active_thread->name); - tcb *sender = (tcb*)n->data; -======= DEBUG("%s: msg_receive(): Wakeing up waiting thread.\n", active_thread->name); tcb *sender = (tcb*)node->data; @@ -236,7 +210,6 @@ int msg_receive(msg* m) { */ m = &(me->msg_array[cib_put(&(me->msg_queue))]); } ->>>>>>> master /* copy msg */ msg* sender_msg = (msg*)sender->wait_data; diff --git a/core/mutex.c b/core/mutex.c index 72fd9cc686..116cc8dde5 100644 --- a/core/mutex.c +++ b/core/mutex.c @@ -20,10 +20,7 @@ #include "tcb.h" #include "kernel.h" #include "sched.h" -<<<<<<< HEAD -======= #include ->>>>>>> master //#define ENABLE_DEBUG #include @@ -39,7 +36,7 @@ int mutex_init(struct mutex_t* mutex) { } int mutex_trylock(struct mutex_t* mutex) { -<<<<<<< HEAD + DEBUG("%s: trylocking to get mutex. val: %u\n", active_thread->name, mutex->val); return (atomic_set_return(&mutex->val, thread_pid ) == 0); } @@ -47,60 +44,24 @@ int prio() { return active_thread->priority; } -int mutex_lock(struct mutex_t* mutex) { - DEBUG("%s: trying to get mutex. val: %u\n", active_thread->name, mutex->val); - - if (atomic_set_return(&mutex->val,thread_pid) != 0) { -======= - DEBUG("%s: trylocking to get mutex. val: %u\n", active_thread->name, mutex->val); - return atomic_set_return(&mutex->val, 1 ) == 0; -} - int mutex_lock(struct mutex_t* mutex) { DEBUG("%s: trying to get mutex. val: %u\n", active_thread->name, mutex->val); if (atomic_set_return(&mutex->val,1) != 0) { ->>>>>>> master // mutex was locked. mutex_wait(mutex); } return 1; } -<<<<<<< HEAD -void mutex_unlock(struct mutex_t* mutex, int yield) { - DEBUG("%s: unlocking mutex. val: %u pid: %u\n", active_thread->name, mutex->val, thread_pid); - int me_value; - - if (inISR()) { - me_value = 0; - yield = MUTEX_INISR; - } else { - me_value = thread_pid; - } - - if (atomic_set_return(&mutex->val,0) != me_value ) { - // there were waiters. - mutex_wake_waiters(mutex, yield); - } -} - -void mutex_wait(struct mutex_t *mutex) { - dINT(); -======= void mutex_wait(struct mutex_t *mutex) { int irqstate = disableIRQ(); ->>>>>>> master DEBUG("%s: Mutex in use. %u\n", active_thread->name, mutex->val); if (mutex->val == 0) { // somebody released the mutex. return. mutex->val = thread_pid; DEBUG("%s: mutex_wait early out. %u\n", active_thread->name, mutex->val); -<<<<<<< HEAD - eINT(); -======= restoreIRQ(irqstate); ->>>>>>> master return; } @@ -111,11 +72,7 @@ void mutex_wait(struct mutex_t *mutex) { n.data = (unsigned int) active_thread; n.next = NULL; -<<<<<<< HEAD - DEBUG("%s: Adding node to mutex queue: prio: %u data: %u\n", active_thread->name, n.priority, n.data); -======= DEBUG("%s: Adding node to mutex queue: prio: %u\n", active_thread->name, n.priority); ->>>>>>> master queue_priority_add(&(mutex->queue), &n); @@ -126,32 +83,6 @@ void mutex_wait(struct mutex_t *mutex) { /* we were woken up by scheduler. waker removed us from queue. we have the mutex now. */ } -<<<<<<< HEAD -void mutex_wake_waiters(struct mutex_t *mutex, int flags) { - if ( ! (flags & MUTEX_INISR)) dINT(); - DEBUG("%s: waking up waiters.\n", active_thread->name); - - queue_node_t *next = queue_remove_head(&(mutex->queue)); - tcb* process = (tcb*)next->data; - - sched_set_status(process, STATUS_PENDING); - - if ( mutex->queue.next != NULL) { - mutex->val = -1; - } else { - mutex->val = process->pid; - } - - DEBUG("%s: waiters woken up.\n", active_thread->name); - - /* If called from process, reenable interrupts, yield if requested */ - if (! (flags & MUTEX_INISR)) { - eINT(); - if (flags & MUTEX_YIELD) thread_yield(); - } else { - sched_context_switch_request = 1; - } -======= void mutex_unlock(struct mutex_t* mutex, int yield) { DEBUG("%s: unlocking mutex. val: %u pid: %u\n", active_thread->name, mutex->val, thread_pid); int irqstate = disableIRQ(); @@ -170,6 +101,5 @@ void mutex_unlock(struct mutex_t* mutex, int yield) { } restoreIRQ(irqstate); ->>>>>>> master } diff --git a/core/sched.c b/core/sched.c index 3ebdbf01bf..0563e46f4f 100644 --- a/core/sched.c +++ b/core/sched.c @@ -14,18 +14,10 @@ */ #include -<<<<<<< HEAD:core/sched.c -#include -#include "sched.h" -#include "kernel.h" -#include "kernel_intern.h" -#include "clist.h" -======= #include #include #include #include ->>>>>>> master:core/sched.c #include //#define ENABLE_DEBUG @@ -151,8 +143,6 @@ void sched_set_status(tcb *process, unsigned int status) { process->status = status; } -<<<<<<< HEAD:core/sched.c -======= void sched_switch(uint16_t current_prio, uint16_t other_prio, int in_isr) { DEBUG("%s: %i %i %i\n", active_thread->name, (int)current_prio, (int)other_prio, in_isr); if (current_prio <= other_prio) { @@ -164,7 +154,6 @@ void sched_switch(uint16_t current_prio, uint16_t other_prio, int in_isr) { } } ->>>>>>> master:core/sched.c extern void cpu_switch_context_exit(void); void sched_task_exit(void) { @@ -173,15 +162,9 @@ void sched_task_exit(void) { dINT(); sched_threads[active_thread->pid] = NULL; num_tasks--; -<<<<<<< HEAD:core/sched.c - sched_set_status((tcb*)active_thread, STATUS_STOPPED); - - free(((tcb*)active_thread)->stack_start); -======= sched_set_status((tcb*)active_thread, STATUS_STOPPED); ->>>>>>> master:core/sched.c active_thread = NULL; cpu_switch_context_exit(); } diff --git a/core/thread.c b/core/thread.c index 43da40f12a..e087f2a9d6 100644 --- a/core/thread.c +++ b/core/thread.c @@ -53,10 +53,7 @@ int thread_wakeup(int pid) { int result = sched_threads[pid]->status; if (result == STATUS_SLEEPING) { -<<<<<<< HEAD -======= DEBUG("thread_wakeup: Thread is sleeping.\n"); ->>>>>>> master sched_set_status((tcb*)sched_threads[pid], STATUS_RUNNING); if (!isr) { eINT(); @@ -124,13 +121,8 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f int pid = 0; while (pid < MAXTHREADS) { if (sched_threads[pid] == NULL) { -<<<<<<< HEAD - sched_threads[pid] = pd; - pd->pid = pid; -======= sched_threads[pid] = cb; cb->pid = pid; ->>>>>>> master break; } pid++; @@ -145,18 +137,12 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f return -EOVERFLOW; } -<<<<<<< HEAD - pd->sp = thread_stack_init(function,stack+stacksize); - pd->stack_start = stack; - pd->stack_size = stacksize; -======= cb->sp = thread_stack_init(function,stack+stacksize); cb->stack_start = stack; cb->stack_size = total_stacksize; cb->priority = priority; cb->status = 0; ->>>>>>> master cb->rq_entry.data = (unsigned int) cb; cb->rq_entry.next = NULL;