1 #ifndef _GPXE_PROCESS_H
2 #define _GPXE_PROCESS_H
10 #include <gpxe/list.h>
11 #include <gpxe/refcnt.h>
12 #include <gpxe/tables.h>
16 /** List of processes */
17 struct list_head list
;
19 * Single-step the process
21 * This method should execute a single step of the process.
22 * Returning from this method is isomorphic to yielding the
23 * CPU to another process.
25 void ( * step
) ( struct process
*process
);
28 * If this interface is not part of a reference-counted
29 * object, this field may be NULL.
31 struct refcnt
*refcnt
;
34 extern void process_add ( struct process
*process
);
35 extern void process_del ( struct process
*process
);
36 extern void step ( void );
39 * Initialise process without adding to process list
42 * @v step Process' step() method
44 static inline __attribute__ (( always_inline
)) void
45 process_init_stopped ( struct process
*process
,
46 void ( * step
) ( struct process
*process
),
47 struct refcnt
*refcnt
) {
49 process
->refcnt
= refcnt
;
53 * Initialise process and add to process list
56 * @v step Process' step() method
58 static inline __attribute__ (( always_inline
)) void
59 process_init ( struct process
*process
,
60 void ( * step
) ( struct process
*process
),
61 struct refcnt
*refcnt
) {
62 process_init_stopped ( process
, step
, refcnt
);
63 process_add ( process
);
67 * Declare a permanent process
69 * Permanent processes will be automatically added to the process list
70 * at initialisation time.
72 #define __permanent_process \
73 __table ( struct process, processes, 01 )
75 #endif /* _GPXE_PROCESS_H */