Browse Source

[process] Add process_running()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
25447294d5
2 changed files with 13 additions and 2 deletions
  1. 2
    2
      src/core/process.c
  2. 11
    0
      src/include/ipxe/process.h

+ 2
- 2
src/core/process.c View File

42
  * have no effect.
42
  * have no effect.
43
  */
43
  */
44
 void process_add ( struct process *process ) {
44
 void process_add ( struct process *process ) {
45
-	if ( list_empty ( &process->list ) ) {
45
+	if ( ! process_running ( process ) ) {
46
 		DBGC ( process, "PROCESS %p starting\n", process );
46
 		DBGC ( process, "PROCESS %p starting\n", process );
47
 		ref_get ( process->refcnt );
47
 		ref_get ( process->refcnt );
48
 		list_add_tail ( &process->list, &run_queue );
48
 		list_add_tail ( &process->list, &run_queue );
60
  * have no effect.
60
  * have no effect.
61
  */
61
  */
62
 void process_del ( struct process *process ) {
62
 void process_del ( struct process *process ) {
63
-	if ( ! list_empty ( &process->list ) ) {
63
+	if ( process_running ( process ) ) {
64
 		DBGC ( process, "PROCESS %p stopping\n", process );
64
 		DBGC ( process, "PROCESS %p stopping\n", process );
65
 		list_del ( &process->list );
65
 		list_del ( &process->list );
66
 		INIT_LIST_HEAD ( &process->list );
66
 		INIT_LIST_HEAD ( &process->list );

+ 11
- 0
src/include/ipxe/process.h View File

66
 	process_add ( process );
66
 	process_add ( process );
67
 }
67
 }
68
 
68
 
69
+/**
70
+ * Check if process is running
71
+ *
72
+ * @v process		Process
73
+ * @ret running		Process is running
74
+ */
75
+static inline __attribute__ (( always_inline )) int
76
+process_running ( struct process *process ) {
77
+	return ( ! list_empty ( &process->list ) );
78
+}
79
+
69
 /** Permanent process table */
80
 /** Permanent process table */
70
 #define PERMANENT_PROCESSES __table ( struct process, "processes" )
81
 #define PERMANENT_PROCESSES __table ( struct process, "processes" )
71
 
82
 

Loading…
Cancel
Save