浏览代码

[process] Add process_running()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 年前
父节点
当前提交
25447294d5
共有 2 个文件被更改,包括 13 次插入2 次删除
  1. 2
    2
      src/core/process.c
  2. 11
    0
      src/include/ipxe/process.h

+ 2
- 2
src/core/process.c 查看文件

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

+ 11
- 0
src/include/ipxe/process.h 查看文件

@@ -66,6 +66,17 @@ process_init ( struct process *process,
66 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 80
 /** Permanent process table */
70 81
 #define PERMANENT_PROCESSES __table ( struct process, "processes" )
71 82
 

正在加载...
取消
保存