diff --git a/src/core/process.c b/src/core/process.c index d46737b0..d968febf 100644 --- a/src/core/process.c +++ b/src/core/process.c @@ -42,7 +42,7 @@ static LIST_HEAD ( run_queue ); * have no effect. */ void process_add ( struct process *process ) { - if ( list_empty ( &process->list ) ) { + if ( ! process_running ( process ) ) { DBGC ( process, "PROCESS %p starting\n", process ); ref_get ( process->refcnt ); list_add_tail ( &process->list, &run_queue ); @@ -60,7 +60,7 @@ void process_add ( struct process *process ) { * have no effect. */ void process_del ( struct process *process ) { - if ( ! list_empty ( &process->list ) ) { + if ( process_running ( process ) ) { DBGC ( process, "PROCESS %p stopping\n", process ); list_del ( &process->list ); INIT_LIST_HEAD ( &process->list ); diff --git a/src/include/ipxe/process.h b/src/include/ipxe/process.h index 7cd5b91a..45c2af63 100644 --- a/src/include/ipxe/process.h +++ b/src/include/ipxe/process.h @@ -66,6 +66,17 @@ process_init ( struct process *process, process_add ( process ); } +/** + * Check if process is running + * + * @v process Process + * @ret running Process is running + */ +static inline __attribute__ (( always_inline )) int +process_running ( struct process *process ) { + return ( ! list_empty ( &process->list ) ); +} + /** Permanent process table */ #define PERMANENT_PROCESSES __table ( struct process, "processes" )