From b9a9e7695de330d0f6d5e64ce00c1ca811733529 Mon Sep 17 00:00:00 2001 From: dak664 Date: Tue, 14 Sep 2010 18:55:04 +0000 Subject: [PATCH] Add option to remove process name strings to save RAM --- core/sys/process.c | 20 ++++++++++---------- core/sys/process.h | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/core/sys/process.c b/core/sys/process.c index 284796d9c..da04bde9a 100644 --- a/core/sys/process.c +++ b/core/sys/process.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: process.c,v 1.10 2010/02/02 21:13:27 adamdunkels Exp $ + * @(#)$Id: process.c,v 1.11 2010/09/14 18:55:04 dak664 Exp $ */ /** @@ -115,7 +115,7 @@ process_start(struct process *p, const char *arg) p->state = PROCESS_STATE_RUNNING; PT_INIT(&p->pt); - PRINTF("process: starting '%s'\n", p->name); + PRINTF("process: starting '%s'\n", PROCESS_NAME_STRING(p)); /* Post a synchronous initialization event to the process. */ process_post_synch(p, PROCESS_EVENT_INIT, (process_data_t)arg); @@ -127,7 +127,7 @@ exit_process(struct process *p, struct process *fromprocess) register struct process *q; struct process *old_current = process_current; - PRINTF("process: exit_process '%s'\n", p->name); + PRINTF("process: exit_process '%s'\n", PROCESS_NAME_STRING(p)); if(process_is_running(p)) { /* Process was running */ @@ -172,13 +172,13 @@ call_process(struct process *p, process_event_t ev, process_data_t data) #if DEBUG if(p->state == PROCESS_STATE_CALLED) { - printf("process: process '%s' called again with event %d\n", p->name, ev); + printf("process: process '%s' called again with event %d\n", PROCESS_NAME_STRING(p), ev); } #endif /* DEBUG */ if((p->state & PROCESS_STATE_RUNNING) && p->thread != NULL) { - PRINTF("process: calling process '%s' with event %d\n", p->name, ev); + PRINTF("process: calling process '%s' with event %d\n", PROCESS_NAME_STRING(p), ev); process_current = p; p->state = PROCESS_STATE_CALLED; ret = p->thread(&p->pt, ev, data); @@ -319,19 +319,19 @@ process_post(struct process *p, process_event_t ev, process_data_t data) if(PROCESS_CURRENT() == NULL) { PRINTF("process_post: NULL process posts event %d to process '%s', nevents %d\n", - ev, p->name, nevents); + ev,PROCESS_NAME_STRING(p), nevents); } else { PRINTF("process_post: Process '%s' posts event %d to process '%s', nevents %d\n", - PROCESS_CURRENT()->name, ev, - p == PROCESS_BROADCAST? "": p->name, nevents); + PROCESS_NAME_STRING(PROCESS_CURRENT()), ev, + p == PROCESS_BROADCAST? "": PROCESS_NAME_STRING(p), nevents); } if(nevents == PROCESS_CONF_NUMEVENTS) { #if DEBUG if(p == PROCESS_BROADCAST) { - printf("soft panic: event queue is full when broadcast event %d was posted from %s\n", ev, process_current->name); + printf("soft panic: event queue is full when broadcast event %d was posted from %s\n", ev, PROCESS_NAME_STRING(process_current)); } else { - printf("soft panic: event queue is full when event %d was posted to %s frpm %s\n", ev, p->name, process_current->name); + printf("soft panic: event queue is full when event %d was posted to %s frpm %s\n", ev, PROCESS_NAME_STRING(p), PROCESS_NAME_STRING(process_current)); } #endif /* DEBUG */ return PROCESS_ERR_FULL; diff --git a/core/sys/process.h b/core/sys/process.h index f1bea6aaf..097ac03cf 100644 --- a/core/sys/process.h +++ b/core/sys/process.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: process.h,v 1.16 2008/10/14 12:46:39 nvt-se Exp $ + * @(#)$Id: process.h,v 1.17 2010/09/14 18:55:04 dak664 Exp $ */ /** @@ -292,22 +292,35 @@ static PT_THREAD(process_thread_##name(struct pt *process_pt, \ * This macro declares a process. The process has two names: the * variable of the process structure, which is used by the C program, * and a human readable string name, which is used when debugging. + * A configuration option allows removal of the readable name to save RAM. * * \param name The variable name of the process structure. * \param strname The string representation of the process' name. * * \hideinitializer */ +#if PROCESS_CONF_NO_PROCESS_NAMES +#define PROCESS(name, strname) \ + PROCESS_THREAD(name, ev, data); \ + struct process name = { NULL, \ + process_thread_##name } +#else #define PROCESS(name, strname) \ PROCESS_THREAD(name, ev, data); \ struct process name = { NULL, strname, \ process_thread_##name } +#endif /** @} */ struct process { struct process *next; +#if PROCESS_CONF_NO_PROCESS_NAMES +#define PROCESS_NAME_STRING(process) "" +#else const char *name; +#define PROCESS_NAME_STRING(process) (process)->name +#endif PT_THREAD((* thread)(struct pt *, process_event_t, process_data_t)); struct pt pt; unsigned char state, needspoll;