branch merge fixes
This commit is contained in:
parent
8264cde342
commit
9efaa3bbb6
@ -28,11 +28,7 @@
|
|||||||
SubDir TOP core ;
|
SubDir TOP core ;
|
||||||
|
|
||||||
Module core : kernel_init.c sched.c mutex.c msg.c queue.c
|
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 ;
|
clist.c thread.c bitarithm.c cib.c ;
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
Module hwtimer : hwtimer.c : hwtimer_cpu ;
|
Module hwtimer : hwtimer.c : hwtimer_cpu ;
|
||||||
|
|
||||||
|
|||||||
@ -17,17 +17,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
<<<<<<< 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 <tcb.h>
|
#include <tcb.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <kernel_intern.h>
|
#include <kernel_intern.h>
|
||||||
@ -37,7 +26,6 @@
|
|||||||
#include <lpm.h>
|
#include <lpm.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <hwtimer.h>
|
#include <hwtimer.h>
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
#ifdef MODULE_AUTO_INIT
|
#ifdef MODULE_AUTO_INIT
|
||||||
#include <auto_init.h>
|
#include <auto_init.h>
|
||||||
@ -85,11 +73,7 @@ void kernel_init(void)
|
|||||||
|
|
||||||
sched_init();
|
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) {
|
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");
|
printf("kernel_init(): error creating idle task.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
core/msg.c
27
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);
|
return msg_send_int(m, target_pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
int result = 1;
|
|
||||||
|
|
||||||
tcb *target = (tcb*)sched_threads[target_pid];
|
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;
|
m->sender_pid = thread_pid;
|
||||||
if (m->sender_pid == target_pid) {
|
if (m->sender_pid == target_pid) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -80,11 +71,7 @@ int msg_send(msg* m, unsigned int target_pid, bool block) {
|
|||||||
queue_node_t n;
|
queue_node_t n;
|
||||||
n.priority = active_thread->priority;
|
n.priority = active_thread->priority;
|
||||||
n.data = (unsigned int) active_thread;
|
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);
|
DEBUG("%s: Adding node to msg_waiters:\n", active_thread->name);
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
queue_priority_add(&(target->msg_waiters), &n);
|
queue_priority_add(&(target->msg_waiters), &n);
|
||||||
|
|
||||||
@ -199,14 +186,6 @@ int msg_receive(msg* m) {
|
|||||||
me->wait_data = (void*) 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));
|
queue_node_t *node = queue_remove_head(&(me->msg_waiters));
|
||||||
|
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
@ -214,7 +193,6 @@ int msg_receive(msg* m) {
|
|||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
DEBUG("%s: msg_receive(): No msg in queue. Going blocked.\n", active_thread->name);
|
DEBUG("%s: msg_receive(): No msg in queue. Going blocked.\n", active_thread->name);
|
||||||
sched_set_status(me, STATUS_RECEIVE_BLOCKED);
|
sched_set_status(me, STATUS_RECEIVE_BLOCKED);
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
eINT();
|
eINT();
|
||||||
thread_yield();
|
thread_yield();
|
||||||
@ -223,10 +201,6 @@ int msg_receive(msg* m) {
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} 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);
|
DEBUG("%s: msg_receive(): Wakeing up waiting thread.\n", active_thread->name);
|
||||||
tcb *sender = (tcb*)node->data;
|
tcb *sender = (tcb*)node->data;
|
||||||
|
|
||||||
@ -236,7 +210,6 @@ int msg_receive(msg* m) {
|
|||||||
*/
|
*/
|
||||||
m = &(me->msg_array[cib_put(&(me->msg_queue))]);
|
m = &(me->msg_array[cib_put(&(me->msg_queue))]);
|
||||||
}
|
}
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
/* copy msg */
|
/* copy msg */
|
||||||
msg* sender_msg = (msg*)sender->wait_data;
|
msg* sender_msg = (msg*)sender->wait_data;
|
||||||
|
|||||||
72
core/mutex.c
72
core/mutex.c
@ -20,10 +20,7 @@
|
|||||||
#include "tcb.h"
|
#include "tcb.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "sched.h"
|
#include "sched.h"
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
//#define ENABLE_DEBUG
|
//#define ENABLE_DEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
@ -39,7 +36,7 @@ int mutex_init(struct mutex_t* mutex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int mutex_trylock(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);
|
return (atomic_set_return(&mutex->val, thread_pid ) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,60 +44,24 @@ int prio() {
|
|||||||
return active_thread->priority;
|
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) {
|
int mutex_lock(struct mutex_t* mutex) {
|
||||||
DEBUG("%s: trying to get mutex. val: %u\n", active_thread->name, mutex->val);
|
DEBUG("%s: trying to get mutex. val: %u\n", active_thread->name, mutex->val);
|
||||||
|
|
||||||
if (atomic_set_return(&mutex->val,1) != 0) {
|
if (atomic_set_return(&mutex->val,1) != 0) {
|
||||||
>>>>>>> master
|
|
||||||
// mutex was locked.
|
// mutex was locked.
|
||||||
mutex_wait(mutex);
|
mutex_wait(mutex);
|
||||||
}
|
}
|
||||||
return 1;
|
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) {
|
void mutex_wait(struct mutex_t *mutex) {
|
||||||
int irqstate = disableIRQ();
|
int irqstate = disableIRQ();
|
||||||
>>>>>>> master
|
|
||||||
DEBUG("%s: Mutex in use. %u\n", active_thread->name, mutex->val);
|
DEBUG("%s: Mutex in use. %u\n", active_thread->name, mutex->val);
|
||||||
if (mutex->val == 0) {
|
if (mutex->val == 0) {
|
||||||
// somebody released the mutex. return.
|
// somebody released the mutex. return.
|
||||||
mutex->val = thread_pid;
|
mutex->val = thread_pid;
|
||||||
DEBUG("%s: mutex_wait early out. %u\n", active_thread->name, mutex->val);
|
DEBUG("%s: mutex_wait early out. %u\n", active_thread->name, mutex->val);
|
||||||
<<<<<<< HEAD
|
|
||||||
eINT();
|
|
||||||
=======
|
|
||||||
restoreIRQ(irqstate);
|
restoreIRQ(irqstate);
|
||||||
>>>>>>> master
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,11 +72,7 @@ void mutex_wait(struct mutex_t *mutex) {
|
|||||||
n.data = (unsigned int) active_thread;
|
n.data = (unsigned int) active_thread;
|
||||||
n.next = NULL;
|
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);
|
DEBUG("%s: Adding node to mutex queue: prio: %u\n", active_thread->name, n.priority);
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
queue_priority_add(&(mutex->queue), &n);
|
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. */
|
/* 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) {
|
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);
|
DEBUG("%s: unlocking mutex. val: %u pid: %u\n", active_thread->name, mutex->val, thread_pid);
|
||||||
int irqstate = disableIRQ();
|
int irqstate = disableIRQ();
|
||||||
@ -170,6 +101,5 @@ void mutex_unlock(struct mutex_t* mutex, int yield) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
restoreIRQ(irqstate);
|
restoreIRQ(irqstate);
|
||||||
>>>>>>> master
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
core/sched.c
17
core/sched.c
@ -14,18 +14,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
<<<<<<< HEAD:core/sched.c
|
|
||||||
#include <malloc.h>
|
|
||||||
#include "sched.h"
|
|
||||||
#include "kernel.h"
|
|
||||||
#include "kernel_intern.h"
|
|
||||||
#include "clist.h"
|
|
||||||
=======
|
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <kernel_intern.h>
|
#include <kernel_intern.h>
|
||||||
#include <clist.h>
|
#include <clist.h>
|
||||||
>>>>>>> master:core/sched.c
|
|
||||||
#include <bitarithm.h>
|
#include <bitarithm.h>
|
||||||
|
|
||||||
//#define ENABLE_DEBUG
|
//#define ENABLE_DEBUG
|
||||||
@ -151,8 +143,6 @@ void sched_set_status(tcb *process, unsigned int status) {
|
|||||||
process->status = status;
|
process->status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD:core/sched.c
|
|
||||||
=======
|
|
||||||
void sched_switch(uint16_t current_prio, uint16_t other_prio, int in_isr) {
|
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);
|
DEBUG("%s: %i %i %i\n", active_thread->name, (int)current_prio, (int)other_prio, in_isr);
|
||||||
if (current_prio <= other_prio) {
|
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);
|
extern void cpu_switch_context_exit(void);
|
||||||
|
|
||||||
void sched_task_exit(void) {
|
void sched_task_exit(void) {
|
||||||
@ -173,15 +162,9 @@ void sched_task_exit(void) {
|
|||||||
dINT();
|
dINT();
|
||||||
sched_threads[active_thread->pid] = NULL;
|
sched_threads[active_thread->pid] = NULL;
|
||||||
num_tasks--;
|
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);
|
sched_set_status((tcb*)active_thread, STATUS_STOPPED);
|
||||||
|
|
||||||
>>>>>>> master:core/sched.c
|
|
||||||
active_thread = NULL;
|
active_thread = NULL;
|
||||||
cpu_switch_context_exit();
|
cpu_switch_context_exit();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,10 +53,7 @@ int thread_wakeup(int pid) {
|
|||||||
|
|
||||||
int result = sched_threads[pid]->status;
|
int result = sched_threads[pid]->status;
|
||||||
if (result == STATUS_SLEEPING) {
|
if (result == STATUS_SLEEPING) {
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
DEBUG("thread_wakeup: Thread is sleeping.\n");
|
DEBUG("thread_wakeup: Thread is sleeping.\n");
|
||||||
>>>>>>> master
|
|
||||||
sched_set_status((tcb*)sched_threads[pid], STATUS_RUNNING);
|
sched_set_status((tcb*)sched_threads[pid], STATUS_RUNNING);
|
||||||
if (!isr) {
|
if (!isr) {
|
||||||
eINT();
|
eINT();
|
||||||
@ -124,13 +121,8 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f
|
|||||||
int pid = 0;
|
int pid = 0;
|
||||||
while (pid < MAXTHREADS) {
|
while (pid < MAXTHREADS) {
|
||||||
if (sched_threads[pid] == NULL) {
|
if (sched_threads[pid] == NULL) {
|
||||||
<<<<<<< HEAD
|
|
||||||
sched_threads[pid] = pd;
|
|
||||||
pd->pid = pid;
|
|
||||||
=======
|
|
||||||
sched_threads[pid] = cb;
|
sched_threads[pid] = cb;
|
||||||
cb->pid = pid;
|
cb->pid = pid;
|
||||||
>>>>>>> master
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pid++;
|
pid++;
|
||||||
@ -145,18 +137,12 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f
|
|||||||
return -EOVERFLOW;
|
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->sp = thread_stack_init(function,stack+stacksize);
|
||||||
cb->stack_start = stack;
|
cb->stack_start = stack;
|
||||||
cb->stack_size = total_stacksize;
|
cb->stack_size = total_stacksize;
|
||||||
|
|
||||||
cb->priority = priority;
|
cb->priority = priority;
|
||||||
cb->status = 0;
|
cb->status = 0;
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
cb->rq_entry.data = (unsigned int) cb;
|
cb->rq_entry.data = (unsigned int) cb;
|
||||||
cb->rq_entry.next = NULL;
|
cb->rq_entry.next = NULL;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user