]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[process] Add process_running()
authorMichael Brown <mcb30@ipxe.org>
Wed, 25 Aug 2010 10:17:13 +0000 (11:17 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 3 Sep 2010 20:26:21 +0000 (21:26 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/process.c
src/include/ipxe/process.h

index d46737b04e908b5877dcfc7eb8f59cf58746f3b8..d968febfab2d4f78f67b3970162e753d143c95d9 100644 (file)
@@ -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 );
index 7cd5b91ac6ace319db03412f2bb18ed514e18eca..45c2af639e5888b4ee0d841a6d9ea4e1c97c50ea 100644 (file)
@@ -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" )