summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe/process.h
diff options
context:
space:
mode:
authorMichael Brown2007-05-26 17:00:56 +0200
committerMichael Brown2007-05-26 17:00:56 +0200
commit360110338147844bfa4612ae2d6351f1d1054626 (patch)
tree2bee0111a128e36f3f958f0a19c311ec1cc1b912 /src/include/gpxe/process.h
parentFree I/O buffers when we are finished with them! (diff)
downloadipxe-360110338147844bfa4612ae2d6351f1d1054626.tar.gz
ipxe-360110338147844bfa4612ae2d6351f1d1054626.tar.xz
ipxe-360110338147844bfa4612ae2d6351f1d1054626.zip
Modify process semantics; rescheduling is now automatic.
Add reference-counting to processes. Add timer_running() test.
Diffstat (limited to 'src/include/gpxe/process.h')
-rw-r--r--src/include/gpxe/process.h41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/include/gpxe/process.h b/src/include/gpxe/process.h
index 83ff83934..c0837fa4f 100644
--- a/src/include/gpxe/process.h
+++ b/src/include/gpxe/process.h
@@ -8,6 +8,7 @@
*/
#include <gpxe/list.h>
+#include <gpxe/refcnt.h>
/** A process */
struct process {
@@ -19,14 +20,46 @@ struct process {
* This method should execute a single step of the process.
* Returning from this method is isomorphic to yielding the
* CPU to another process.
- *
- * If the process wishes to be executed again, it must re-add
- * itself to the run queue using schedule().
*/
void ( * step ) ( struct process *process );
+ /** Reference counter
+ *
+ * If this interface is not part of a reference-counted
+ * object, this field may be NULL.
+ */
+ struct refcnt *refcnt;
};
-extern void schedule ( struct process *process );
+extern void process_add ( struct process *process );
+extern void process_del ( struct process *process );
extern void step ( void );
+/**
+ * Initialise process without adding to process list
+ *
+ * @v process Process
+ * @v step Process' step() method
+ */
+static inline __attribute__ (( always_inline )) void
+process_init_stopped ( struct process *process,
+ void ( * step ) ( struct process *process ),
+ struct refcnt *refcnt ) {
+ process->step = step;
+ process->refcnt = refcnt;
+}
+
+/**
+ * Initialise process and add to process list
+ *
+ * @v process Process
+ * @v step Process' step() method
+ */
+static inline __attribute__ (( always_inline )) void
+process_init ( struct process *process,
+ void ( * step ) ( struct process *process ),
+ struct refcnt *refcnt ) {
+ process_init_stopped ( process, step, refcnt );
+ process_add ( process );
+}
+
#endif /* _GPXE_PROCESS_H */