mirror of
https://github.com/xcat2/xNBA.git
synced 2025-02-06 22:11:57 +00:00
[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>
This commit is contained in:
parent
e01ec74601
commit
ccc2655540
@ -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 );
|
||||
|
@ -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 ))
|
||||
|
Loading…
x
Reference in New Issue
Block a user