From: bernie Date: Thu, 7 Aug 2008 09:48:45 +0000 (+0000) Subject: kern: Unify stack_base/stack_size copies in Process X-Git-Tag: 2.0.0~373 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=dc9c2e09cf5e9837cdd3106c57db749301c5bf95;p=bertos.git kern: Unify stack_base/stack_size copies in Process git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1561 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/kern/monitor.c b/bertos/kern/monitor.c index 96b563e1..14fac07b 100644 --- a/bertos/kern/monitor.c +++ b/bertos/kern/monitor.c @@ -59,11 +59,9 @@ void monitor_init(void) } -void monitor_add(Process* proc, const char* name, cpustack_t* stack_base, size_t stack_size) +void monitor_add(Process *proc, const char *name) { proc->monitor.name = name; - proc->monitor.stack_base = stack_base; - proc->monitor.stack_size = stack_size; ADDTAIL(&MonitorProcs, &proc->monitor.link); } @@ -74,7 +72,7 @@ void monitor_remove(Process* proc) REMOVE(&proc->monitor.link); } -void monitor_rename(Process *proc, const char* name) +void monitor_rename(Process *proc, const char *name) { proc->monitor.name = name; } @@ -83,7 +81,7 @@ void monitor_rename(Process *proc, const char* name) #define MONITOR_NODE_TO_PROCESS(node) \ (struct Process *)((intptr_t)(node) - offsetof(struct Process, monitor.link)) -size_t monitor_checkStack(cpustack_t* stack_base, size_t stack_size) +size_t monitor_checkStack(cpustack_t *stack_base, size_t stack_size) { cpustack_t* beg; cpustack_t* cur; @@ -137,9 +135,9 @@ void monitor_report(void) p->monitor.link.succ; p = MONITOR_NODE_TO_PROCESS(p->monitor.link.succ)) { - size_t free = monitor_checkStack(p->monitor.stack_base, p->monitor.stack_size); + size_t free = monitor_checkStack(p->stack_base, p->stack_size); kprintf("%-24s%-8p%-8p%-8lu%-8lu\n", - p->monitor.name, p, p->monitor.stack_base, p->monitor.stack_size, free); + p->monitor.name, p, p->stack_base, p->stack_size, free); } } @@ -154,7 +152,7 @@ static void NORETURN monitor(void) p->monitor.link.succ; p = MONITOR_NODE_TO_PROCESS(p->monitor.link.succ)) { - size_t free = monitor_checkStack(p->monitor.stack_base, p->monitor.stack_size); + size_t free = monitor_checkStack(p->stack_base, p->stack_size); if (free < 0x20) kprintf("MONITOR: WARNING: Free stack for process '%s' is only %u chars\n", diff --git a/bertos/kern/proc.c b/bertos/kern/proc.c index 800fc8e1..32e3afe8 100644 --- a/bertos/kern/proc.c +++ b/bertos/kern/proc.c @@ -199,11 +199,13 @@ struct Process *proc_new_with_name(UNUSED(const char *, name), void (*entry)(voi proc_init_struct(proc); proc->user_data = data; -#if CONFIG_KERN_HEAP +#if CONFIG_KERN_HEAP | CONFIG_KERN_MONITOR | (ARCH & ARCH_EMUL) proc->stack_base = stack_base; proc->stack_size = stack_size; + #if CONFIG_KERN_HEAP if (free_stack) proc->flags |= PF_FREESTACK; + #endif #endif /* Initialize process stack frame */ @@ -218,7 +220,7 @@ struct Process *proc_new_with_name(UNUSED(const char *, name), void (*entry)(voi ATOMIC(SCHED_ENQUEUE(proc)); #if CONFIG_KERN_MONITOR - monitor_add(proc, name, stack_base, stack_size); + monitor_add(proc, name); #endif return proc; diff --git a/bertos/kern/proc_p.h b/bertos/kern/proc_p.h index 3b25e360..7dad780d 100644 --- a/bertos/kern/proc_p.h +++ b/bertos/kern/proc_p.h @@ -65,6 +65,9 @@ typedef struct Process #if CONFIG_KERN_HEAP uint16_t flags; /**< Flags */ +#endif + +#if CONFIG_KERN_HEAP | CONFIG_KERN_MONITOR | (ARCH & ARCH_EMUL) cpustack_t *stack_base; /**< Base of process stack */ size_t stack_size; /**< Size of process stack */ #endif @@ -74,8 +77,6 @@ typedef struct Process { Node link; const char *name; - cpustack_t *stack_base; - size_t stack_size; } monitor; #endif @@ -108,13 +109,13 @@ void proc_schedule(void); void monitor_init(void); /** Register a process into the monitor */ - void monitor_add(Process *proc, const char *name, cpustack_t *stack, size_t stacksize); + void monitor_add(Process *proc, const char *name); /** Unregister a process from the monitor */ void monitor_remove(Process *proc); /** Rename a process */ - void monitor_rename(Process *proc, const char* name); + void monitor_rename(Process *proc, const char *name); #endif /* CONFIG_KERN_MONITOR */ #endif /* KERN_PROC_P_H */