summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2011-06-24 15:18:48 +0200
committerMichael Brown2011-06-28 15:45:09 +0200
commitccc2655540f01cc4da018fc31fa16ce8cdb1f4b5 (patch)
treed1ba1902a58b9257ab30ec1ac643a707336dbfbb /src
parent[process] Pass containing object pointer to process step() methods (diff)
downloadipxe-ccc2655540f01cc4da018fc31fa16ce8cdb1f4b5.tar.gz
ipxe-ccc2655540f01cc4da018fc31fa16ce8cdb1f4b5.tar.xz
ipxe-ccc2655540f01cc4da018fc31fa16ce8cdb1f4b5.zip
[process] Add support for one-shot processes
Some processes execute only once, and exist solely in order to defer execution until after the relevant instantiator method has returned. Such processes do not need to be automatically rescheduled when executing. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r--src/core/process.c8
-rw-r--r--src/include/ipxe/process.h18
2 files changed, 24 insertions, 2 deletions
diff --git a/src/core/process.c b/src/core/process.c
index c6660f22..4a705ef6 100644
--- a/src/core/process.c
+++ b/src/core/process.c
@@ -100,8 +100,12 @@ void step ( void ) {
ref_get ( process->refcnt ); /* Inhibit destruction mid-step */
desc = process->desc;
object = process_object ( process );
- list_del ( &process->list );
- list_add_tail ( &process->list, &run_queue );
+ if ( desc->reschedule ) {
+ list_del ( &process->list );
+ list_add_tail ( &process->list, &run_queue );
+ } else {
+ process_del ( process );
+ }
DBGC2 ( PROC_COL ( process ), "PROCESS " PROC_FMT
" executing\n", PROC_DBG ( process ) );
desc->step ( object );
diff --git a/src/include/ipxe/process.h b/src/include/ipxe/process.h
index f8b10a8a..9b757981 100644
--- a/src/include/ipxe/process.h
+++ b/src/include/ipxe/process.h
@@ -39,6 +39,8 @@ struct process_descriptor {
* CPU to another process.
*/
void ( * step ) ( void *object );
+ /** Automatically reschedule the process */
+ int reschedule;
};
/**
@@ -78,6 +80,21 @@ struct process_descriptor {
#define PROC_DESC( object_type, process, _step ) { \
.offset = process_offset ( object_type, process ), \
.step = PROC_STEP ( object_type, _step ), \
+ .reschedule = 1, \
+ }
+
+/**
+ * Define a process descriptor for a process that runs only once
+ *
+ * @v object_type Containing object data type
+ * @v process Process name (i.e. field within object data type)
+ * @v step Process' step() method
+ * @ret desc Object interface descriptor
+ */
+#define PROC_DESC_ONCE( object_type, process, _step ) { \
+ .offset = process_offset ( object_type, process ), \
+ .step = PROC_STEP ( object_type, _step ), \
+ .reschedule = 0, \
}
/**
@@ -91,6 +108,7 @@ struct process_descriptor {
#define PROC_DESC_PURE( _step ) { \
.offset = 0, \
.step = PROC_STEP ( struct process, _step ), \
+ .reschedule = 1, \
}
extern void * __attribute__ (( pure ))