Subversion Repositories Kolibri OS

Rev

Rev 5272 | Rev 6102 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * workqueue.h --- work queue handling for Linux.
  3.  */
  4.  
  5. #ifndef _LINUX_WORKQUEUE_H
  6. #define _LINUX_WORKQUEUE_H
  7.  
  8. #include <linux/list.h>
  9. #include <linux/linkage.h>
  10. #include <linux/lockdep.h>
  11. #include <linux/threads.h>
  12. #include <linux/atomic.h>
  13.  
  14. #include <syscall.h>
  15. struct workqueue_struct;
  16.  
  17. struct work_struct;
  18. typedef void (*work_func_t)(struct work_struct *work);
  19. void __stdcall delayed_work_timer_fn(unsigned long __data);
  20.  
  21. /*
  22.  * Workqueue flags and constants.  For details, please refer to
  23.  * Documentation/workqueue.txt.
  24.  */
  25. enum {
  26.     WQ_NON_REENTRANT    = 1 << 0, /* guarantee non-reentrance */
  27.     WQ_UNBOUND          = 1 << 1, /* not bound to any cpu */
  28.     WQ_FREEZABLE        = 1 << 2, /* freeze during suspend */
  29.     WQ_MEM_RECLAIM      = 1 << 3, /* may be used for memory reclaim */
  30.     WQ_HIGHPRI          = 1 << 4, /* high priority */
  31.     WQ_CPU_INTENSIVE    = 1 << 5, /* cpu instensive workqueue */
  32.  
  33.     WQ_DRAINING         = 1 << 6, /* internal: workqueue is draining */
  34.     WQ_RESCUER          = 1 << 7, /* internal: workqueue has rescuer */
  35.  
  36.     WQ_MAX_ACTIVE       = 512,    /* I like 512, better ideas? */
  37.     WQ_MAX_UNBOUND_PER_CPU  = 4,      /* 4 * #cpus for unbound wq */
  38.     WQ_DFL_ACTIVE       = WQ_MAX_ACTIVE / 2,
  39. };
  40.  
  41.  
  42. struct workqueue_struct {
  43.     spinlock_t lock;
  44.     struct list_head worklist;
  45.     struct list_head delayed_worklist;
  46. };
  47.  
  48. struct work_struct {
  49.     struct list_head entry;
  50.     struct workqueue_struct *data;
  51.     work_func_t func;
  52. #ifdef CONFIG_LOCKDEP
  53.         struct lockdep_map lockdep_map;
  54. #endif
  55. };
  56.  
  57. struct delayed_work {
  58.     struct work_struct work;
  59.     unsigned int delay;
  60. };
  61.  
  62. static inline struct delayed_work *to_delayed_work(struct work_struct *work)
  63. {
  64.         return container_of(work, struct delayed_work, work);
  65. }
  66.  
  67. extern struct workqueue_struct *system_wq;
  68.  
  69. void run_workqueue(struct workqueue_struct *cwq);
  70.  
  71. struct workqueue_struct *alloc_workqueue_key(const char *fmt,
  72.                            unsigned int flags, int max_active);
  73.  
  74.  
  75. #define alloc_ordered_workqueue(fmt, flags, args...)            \
  76.         alloc_workqueue(fmt, WQ_UNBOUND | (flags), 1, ##args)
  77.  
  78. bool queue_work(struct workqueue_struct *wq, struct work_struct *work);
  79. int queue_delayed_work(struct workqueue_struct *wq,
  80.                         struct delayed_work *dwork, unsigned long delay);
  81.  
  82. bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay);
  83.  
  84.  
  85. #define INIT_WORK(_work, _func)                 \
  86.     do {                                        \
  87.         INIT_LIST_HEAD(&(_work)->entry);        \
  88.         (_work)->func = _func;                  \
  89.     } while (0)
  90.  
  91.  
  92. #define INIT_DELAYED_WORK(_work, _func)         \
  93.     do {                                        \
  94.         INIT_LIST_HEAD(&(_work)->work.entry);   \
  95.         (_work)->work.func = _func;             \
  96.     } while (0)
  97.  
  98. static inline bool schedule_work(struct work_struct *work)
  99. {
  100.     return queue_work(system_wq, work);
  101. }
  102.  
  103.  
  104. #endif  /*  _LINUX_WORKQUEUE_H  */
  105.