Add option to remove process name strings to save RAM

This commit is contained in:
dak664 2010-09-14 18:55:04 +00:00
parent b9b4f07ad9
commit b9a9e7695d
2 changed files with 24 additions and 11 deletions

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * 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; p->state = PROCESS_STATE_RUNNING;
PT_INIT(&p->pt); 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. */ /* Post a synchronous initialization event to the process. */
process_post_synch(p, PROCESS_EVENT_INIT, (process_data_t)arg); 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; register struct process *q;
struct process *old_current = process_current; 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)) { if(process_is_running(p)) {
/* Process was running */ /* Process was running */
@ -172,13 +172,13 @@ call_process(struct process *p, process_event_t ev, process_data_t data)
#if DEBUG #if DEBUG
if(p->state == PROCESS_STATE_CALLED) { 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 */ #endif /* DEBUG */
if((p->state & PROCESS_STATE_RUNNING) && if((p->state & PROCESS_STATE_RUNNING) &&
p->thread != NULL) { 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; process_current = p;
p->state = PROCESS_STATE_CALLED; p->state = PROCESS_STATE_CALLED;
ret = p->thread(&p->pt, ev, data); 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) { if(PROCESS_CURRENT() == NULL) {
PRINTF("process_post: NULL process posts event %d to process '%s', nevents %d\n", 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 { } else {
PRINTF("process_post: Process '%s' posts event %d to process '%s', nevents %d\n", PRINTF("process_post: Process '%s' posts event %d to process '%s', nevents %d\n",
PROCESS_CURRENT()->name, ev, PROCESS_NAME_STRING(PROCESS_CURRENT()), ev,
p == PROCESS_BROADCAST? "<broadcast>": p->name, nevents); p == PROCESS_BROADCAST? "<broadcast>": PROCESS_NAME_STRING(p), nevents);
} }
if(nevents == PROCESS_CONF_NUMEVENTS) { if(nevents == PROCESS_CONF_NUMEVENTS) {
#if DEBUG #if DEBUG
if(p == PROCESS_BROADCAST) { 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 { } 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 */ #endif /* DEBUG */
return PROCESS_ERR_FULL; return PROCESS_ERR_FULL;

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * 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 * This macro declares a process. The process has two names: the
* variable of the process structure, which is used by the C program, * variable of the process structure, which is used by the C program,
* and a human readable string name, which is used when debugging. * 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 name The variable name of the process structure.
* \param strname The string representation of the process' name. * \param strname The string representation of the process' name.
* *
* \hideinitializer * \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) \ #define PROCESS(name, strname) \
PROCESS_THREAD(name, ev, data); \ PROCESS_THREAD(name, ev, data); \
struct process name = { NULL, strname, \ struct process name = { NULL, strname, \
process_thread_##name } process_thread_##name }
#endif
/** @} */ /** @} */
struct process { struct process {
struct process *next; struct process *next;
#if PROCESS_CONF_NO_PROCESS_NAMES
#define PROCESS_NAME_STRING(process) ""
#else
const char *name; const char *name;
#define PROCESS_NAME_STRING(process) (process)->name
#endif
PT_THREAD((* thread)(struct pt *, process_event_t, process_data_t)); PT_THREAD((* thread)(struct pt *, process_event_t, process_data_t));
struct pt pt; struct pt pt;
unsigned char state, needspoll; unsigned char state, needspoll;