You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

process.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef _GPXE_PROCESS_H
  2. #define _GPXE_PROCESS_H
  3. /** @file
  4. *
  5. * Processes
  6. *
  7. */
  8. #include <gpxe/list.h>
  9. #include <gpxe/refcnt.h>
  10. #include <gpxe/tables.h>
  11. /** A process */
  12. struct process {
  13. /** List of processes */
  14. struct list_head list;
  15. /**
  16. * Single-step the process
  17. *
  18. * This method should execute a single step of the process.
  19. * Returning from this method is isomorphic to yielding the
  20. * CPU to another process.
  21. */
  22. void ( * step ) ( struct process *process );
  23. /** Reference counter
  24. *
  25. * If this interface is not part of a reference-counted
  26. * object, this field may be NULL.
  27. */
  28. struct refcnt *refcnt;
  29. };
  30. extern void process_add ( struct process *process );
  31. extern void process_del ( struct process *process );
  32. extern void step ( void );
  33. /**
  34. * Initialise process without adding to process list
  35. *
  36. * @v process Process
  37. * @v step Process' step() method
  38. */
  39. static inline __attribute__ (( always_inline )) void
  40. process_init_stopped ( struct process *process,
  41. void ( * step ) ( struct process *process ),
  42. struct refcnt *refcnt ) {
  43. process->step = step;
  44. process->refcnt = refcnt;
  45. }
  46. /**
  47. * Initialise process and add to process list
  48. *
  49. * @v process Process
  50. * @v step Process' step() method
  51. */
  52. static inline __attribute__ (( always_inline )) void
  53. process_init ( struct process *process,
  54. void ( * step ) ( struct process *process ),
  55. struct refcnt *refcnt ) {
  56. process_init_stopped ( process, step, refcnt );
  57. process_add ( process );
  58. }
  59. /**
  60. * Declare a permanent process
  61. *
  62. * Permanent processes will be automatically added to the process list
  63. * at initialisation time.
  64. */
  65. #define __permanent_process \
  66. __table ( struct process, processes, 01 )
  67. #endif /* _GPXE_PROCESS_H */