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.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. /** A process */
  11. struct process {
  12. /** List of processes */
  13. struct list_head list;
  14. /**
  15. * Single-step the process
  16. *
  17. * This method should execute a single step of the process.
  18. * Returning from this method is isomorphic to yielding the
  19. * CPU to another process.
  20. */
  21. void ( * step ) ( struct process *process );
  22. /** Reference counter
  23. *
  24. * If this interface is not part of a reference-counted
  25. * object, this field may be NULL.
  26. */
  27. struct refcnt *refcnt;
  28. };
  29. extern void process_add ( struct process *process );
  30. extern void process_del ( struct process *process );
  31. extern void step ( void );
  32. /**
  33. * Initialise process without adding to process list
  34. *
  35. * @v process Process
  36. * @v step Process' step() method
  37. */
  38. static inline __attribute__ (( always_inline )) void
  39. process_init_stopped ( struct process *process,
  40. void ( * step ) ( struct process *process ),
  41. struct refcnt *refcnt ) {
  42. process->step = step;
  43. process->refcnt = refcnt;
  44. }
  45. /**
  46. * Initialise process and add to process list
  47. *
  48. * @v process Process
  49. * @v step Process' step() method
  50. */
  51. static inline __attribute__ (( always_inline )) void
  52. process_init ( struct process *process,
  53. void ( * step ) ( struct process *process ),
  54. struct refcnt *refcnt ) {
  55. process_init_stopped ( process, step, refcnt );
  56. process_add ( process );
  57. }
  58. #endif /* _GPXE_PROCESS_H */