diff options
author | Michael Brown | 2007-05-26 17:00:56 +0200 |
---|---|---|
committer | Michael Brown | 2007-05-26 17:00:56 +0200 |
commit | 360110338147844bfa4612ae2d6351f1d1054626 (patch) | |
tree | 2bee0111a128e36f3f958f0a19c311ec1cc1b912 /src/core/process.c | |
parent | Free I/O buffers when we are finished with them! (diff) | |
download | ipxe-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/core/process.c')
-rw-r--r-- | src/core/process.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/core/process.c b/src/core/process.c index c087f16d..0583a398 100644 --- a/src/core/process.c +++ b/src/core/process.c @@ -31,25 +31,43 @@ static LIST_HEAD ( run_queue ); /** - * Add process to run queue + * Add process to process list * * @v process Process */ -void schedule ( struct process *process ) { +void process_add ( struct process *process ) { + ref_get ( process->refcnt ); list_add_tail ( &process->list, &run_queue ); } /** + * Remove process from process list + * + * @v process Process + * + * It is safe to call process_del() multiple times; further calls will + * have no effect. + */ +void process_del ( struct process *process ) { + if ( ! list_empty ( &process->list ) ) { + list_del ( &process->list ); + INIT_LIST_HEAD ( &process->list ); + ref_put ( process->refcnt ); + } +} + +/** * Single-step a single process * - * This removes the first process from the run queue and executes a - * single step of that process. + * This executes a single step of the first process in the run queue, + * and moves the process to the end of the run queue. */ void step ( void ) { struct process *process; list_for_each_entry ( process, &run_queue, list ) { list_del ( &process->list ); + list_add_tail ( &process->list, &run_queue ); process->step ( process ); break; } |