Lower half of Interrupt

Source: Internet
Author: User

From: http://blog.csdn.net/sudolee/article/details/6885634

1> work_queue: <linux/workqueue. h> _ 3.0.4
2> description:
The lower part of the interrupt is executed in the context of the kernel thread.
It is the only implementation mechanism that can run in the lower half of the process context, and it can only sleep.
3> Create a push task:

[Html]View plaincopy

  1. DECLARE_WORK (const char * name, void (* func) (struct work_struct * work ));
  2. INIT_WORK (struct work_struct * work, void (* func) (struct work_struct * work ));
  3. Struct work_struct {
  4. Atomic_long_t data;
  5. Struct list_head entry;
  6. Work_func_t func;
  7. # Ifdef CONFIG_LOCKDEP
  8. Struct lockdep_map;
  9. # Endif
  10. };
  11. Typedef void (* work_func_t) (struct work_struct * work );

4> work queue processing functions:

[Html]View plaincopy

  1. /* Apart from being unable to access the user space, it is indeed much more convenient than Soft Interrupt and tasklet.
  2. * The user space memory is mapped only when the system call falls into the kernel.
  3. */
  4. Void * func (struct work_struct * work );

5> Scheduling (submit:

[Html]View plaincopy

  1. /* Submit the created job to the default worker thread (one for each cpu, event/cpuno .).
  2. * Sometimes this kind of work queue is also called a shared queue, because many drivers submit jobs that are pushed back to the default worker thread.
  3. */
  4. Int schedule_work (struct work_struct * work );
  5. Int schedule_delayed_work (struct delayed_work * work, unsigned long delay );
  6. Int schedule_on_each_cpu (work_func_t func );

6> refresh the working queue:

[Html]View plaincopy

  1. /* In fact, it only waits (sleep) until the work on the default Task Force column is executed.
  2. * Complete () implementation.
  3. */
  4. Void flush_scheduled_work (void );
  5. /* Wait for the specified job to be executed */
  6. Bool flush_work (struct work_struct * work );
  7. Bool flush_delayed_work (struct delayed_work * dwork );

7> cancel work:

[Cpp]View plaincopy

  1. Bool cancel_delayed_work (struct delayed_work * work );
  2. Bool cancel_work_sync (struct work_struct * work );
  3. Bool cancel_delayed_work_sync (struct delayed_work * dwork );

 

 

8> Create a New workqueue and corresponding worker thread (one for each cpu ).

[Cpp]View plaincopy

  1. /* If a task is processor-intensive and has strict performance requirements
  2. * You can create your own worker (worker) thread.
  3. * Of course, each processor has one.
  4. */
  5. Struct workqueue_struct * create_workqueue (const char * name );
  6. /* Struct workqueue_struct * alloc_workqueue (const char * name, unsigned int flags, int max_active );
  7. * The maximum number of execution contexts per cpu, up to 512.
  8. */

9> Scheduling (submit) queue

[Cpp]View plaincopy

  1. Int queue_work (struct workqueue_struct * wq, struct work_struct * work );
  2. Int queue_delayed_work (struct workqueue_struct * wq, struct delayed_work * work, unsigned long delay );

10> refresh a work queue:

[Cpp]View plaincopy

  1. /* Wait (sleep) until the job in the specified queue is executed.
  2. * In fact, it is no different from flush_scheduled_work () except for the specified work queue.
  3. */
  4. Void flush_workqueue (struct workqueue_struct * wq );

11> release a working queue:

[Cpp]View plaincopy

    1. Void destroy_workqueue (struct workqueue_struct * wq );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.