process.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 FILE_LICENCE ( GPL2_OR_LATER );
00020
00021 #include <gpxe/list.h>
00022 #include <gpxe/init.h>
00023 #include <gpxe/process.h>
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 static LIST_HEAD ( run_queue );
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 void process_add ( struct process *process ) {
00045 if ( list_empty ( &process->list ) ) {
00046 DBGC ( process, "PROCESS %p starting\n", process );
00047 ref_get ( process->refcnt );
00048 list_add_tail ( &process->list, &run_queue );
00049 } else {
00050 DBGC ( process, "PROCESS %p already started\n", process );
00051 }
00052 }
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 void process_del ( struct process *process ) {
00063 if ( ! list_empty ( &process->list ) ) {
00064 DBGC ( process, "PROCESS %p stopping\n", process );
00065 list_del ( &process->list );
00066 INIT_LIST_HEAD ( &process->list );
00067 ref_put ( process->refcnt );
00068 } else {
00069 DBGC ( process, "PROCESS %p already stopped\n", process );
00070 }
00071 }
00072
00073
00074
00075
00076
00077
00078
00079 void step ( void ) {
00080 struct process *process;
00081
00082 list_for_each_entry ( process, &run_queue, list ) {
00083 list_del ( &process->list );
00084 list_add_tail ( &process->list, &run_queue );
00085 DBGC2 ( process, "PROCESS %p executing\n", process );
00086 process->step ( process );
00087 DBGC2 ( process, "PROCESS %p finished executing\n", process );
00088 break;
00089 }
00090 }
00091
00092
00093
00094
00095
00096 static void init_processes ( void ) {
00097 struct process *process;
00098
00099 for_each_table_entry ( process, PERMANENT_PROCESSES )
00100 process_add ( process );
00101 }
00102
00103
00104 struct init_fn process_init_fn __init_fn ( INIT_NORMAL ) = {
00105 .initialise = init_processes,
00106 };