process.h

Go to the documentation of this file.
00001 #ifndef _GPXE_PROCESS_H
00002 #define _GPXE_PROCESS_H
00003 
00004 /** @file
00005  *
00006  * Processes
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011 
00012 #include <gpxe/list.h>
00013 #include <gpxe/refcnt.h>
00014 #include <gpxe/tables.h>
00015 
00016 /** A process */
00017 struct process {
00018         /** List of processes */
00019         struct list_head list;
00020         /**
00021          * Single-step the process
00022          *
00023          * This method should execute a single step of the process.
00024          * Returning from this method is isomorphic to yielding the
00025          * CPU to another process.
00026          */
00027         void ( * step ) ( struct process *process );
00028         /** Reference counter
00029          *
00030          * If this interface is not part of a reference-counted
00031          * object, this field may be NULL.
00032          */
00033         struct refcnt *refcnt;
00034 };
00035 
00036 extern void process_add ( struct process *process );
00037 extern void process_del ( struct process *process );
00038 extern void step ( void );
00039 
00040 /**
00041  * Initialise process without adding to process list
00042  *
00043  * @v process           Process
00044  * @v step              Process' step() method
00045  */
00046 static inline __attribute__ (( always_inline )) void
00047 process_init_stopped ( struct process *process,
00048                        void ( * step ) ( struct process *process ),
00049                        struct refcnt *refcnt ) {
00050         INIT_LIST_HEAD ( &process->list );
00051         process->step = step;
00052         process->refcnt = refcnt;
00053 }
00054 
00055 /**
00056  * Initialise process and add to process list
00057  *
00058  * @v process           Process
00059  * @v step              Process' step() method
00060  */
00061 static inline __attribute__ (( always_inline )) void
00062 process_init ( struct process *process,
00063                void ( * step ) ( struct process *process ),
00064                struct refcnt *refcnt ) {
00065         process_init_stopped ( process, step, refcnt );
00066         process_add ( process );
00067 }
00068 
00069 /** Permanent process table */
00070 #define PERMANENT_PROCESSES __table ( struct process, "processes" )
00071 
00072 /**
00073  * Declare a permanent process
00074  *
00075  * Permanent processes will be automatically added to the process list
00076  * at initialisation time.
00077  */
00078 #define __permanent_process __table_entry ( PERMANENT_PROCESSES, 01 )
00079 
00080 #endif /* _GPXE_PROCESS_H */

Generated on Tue Apr 6 20:01:08 2010 for gPXE by  doxygen 1.5.7.1