* Add process to process list
*
* @v process Process
+ *
+ * It is safe to call process_add() multiple times; further calls will
+ * have no effect.
*/
void process_add ( struct process *process ) {
- DBGC ( process, "PROCESS %p starting\n", process );
- ref_get ( process->refcnt );
- list_add_tail ( &process->list, &run_queue );
+ if ( list_empty ( &process->list ) ) {
+ DBGC ( process, "PROCESS %p starting\n", process );
+ ref_get ( process->refcnt );
+ list_add_tail ( &process->list, &run_queue );
+ } else {
+ DBGC ( process, "PROCESS %p already started\n", process );
+ }
}
/**
process_init_stopped ( struct process *process,
void ( * step ) ( struct process *process ),
struct refcnt *refcnt ) {
+ INIT_LIST_HEAD ( &process->list );
process->step = step;
process->refcnt = refcnt;
}
/** Infiniband event queue process */
struct process ib_process __permanent_process = {
+ .list = LIST_HEAD_INIT ( ib_process.list ),
.step = ib_step,
};
/** Networking stack process */
struct process net_process __permanent_process = {
+ .list = LIST_HEAD_INIT ( net_process.list ),
.step = net_step,
};
/** Retry timer process */
struct process retry_process __permanent_process = {
+ .list = LIST_HEAD_INIT ( retry_process.list ),
.step = retry_step,
};