Changeset 8a64e81e in mainline


Ignore:
Timestamp:
2012-07-06T13:31:02Z (12 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0d56712
Parents:
518dd43
Message:

workq: Add work queues: allow blocking work items, queuing items from interrupt handlers.

Location:
kernel
Files:
9 added
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r518dd43 r8a64e81e  
    252252        generic/src/synch/waitq.c \
    253253        generic/src/synch/futex.c \
     254        generic/src/synch/workqueue.c \
    254255        generic/src/synch/rcu.c \
    255256        generic/src/smp/ipi.c \
     
    303304                test/synch/semaphore1.c \
    304305                test/synch/semaphore2.c \
     306                test/synch/workqueue1.c \
     307                test/synch/workqueue2.c \
     308                test/synch/workqueue3.c \
    305309                test/print/print1.c \
    306310                test/print/print2.c \
  • kernel/generic/include/proc/thread.h

    r518dd43 r8a64e81e  
    180180        /** Thread ID. */
    181181        thread_id_t tid;
     182
     183        /** Work queue this thread belongs to or NULL. Immutable. */
     184        struct work_queue *workq;
     185        /** Links work queue threads. Protected by workq->lock. */
     186        link_t workq_link;
     187        /** True if the worker was blocked and is not running.
     188         *
     189         * Protected by thread->lock.
     190         */
     191        bool workq_blocked;
     192        /** True if the worker will block in order to become idle.
     193         *
     194         * Protected by workq->lock.
     195         */
     196        bool workq_idling;
    182197       
    183198        /** Architecture-specific data. */
  • kernel/generic/src/console/cmd.c

    r518dd43 r8a64e81e  
    6868#include <sysinfo/sysinfo.h>
    6969#include <symtab.h>
     70#include <synch/workqueue.h>
    7071#include <errno.h>
    7172
     
    447448        .argc = 1,
    448449        .argv = &zone_argv
     450};
     451
     452/* Data and methods for the 'workq' command */
     453static int cmd_workq(cmd_arg_t *argv);
     454static cmd_info_t workq_info = {
     455        .name = "workq",
     456        .description = "Show global workq information.",
     457        .func = cmd_workq,
     458        .argc = 0
    449459};
    450460
     
    522532        &uptime_info,
    523533        &version_info,
     534        &workq_info,
    524535        &zones_info,
    525536        &zone_info,
     
    10151026}
    10161027
     1028/** Prints information about the global work queue.
     1029 *
     1030 * @param argv Ignores
     1031 *
     1032 * @return Always 1
     1033 */
     1034int cmd_workq(cmd_arg_t *argv)
     1035{
     1036        workq_global_print_info();
     1037        return 1;
     1038}
     1039
     1040
    10171041/** Command for listing memory zones
    10181042 *
  • kernel/generic/src/main/kinit.c

    r518dd43 r8a64e81e  
    7777#include <synch/waitq.h>
    7878#include <synch/spinlock.h>
     79#include <synch/workqueue.h>
    7980
    8081#define ALIVE_CHARS  4
     
    103104         */
    104105        thread_detach(THREAD);
    105        
     106
    106107        interrupts_disable();
     108       
     109        /*
     110         * Start processing work queue items. Some may have been queued during boot.
     111         */
     112        workq_global_worker_init();
    107113       
    108114#ifdef CONFIG_SMP
  • kernel/generic/src/main/main.c

    r518dd43 r8a64e81e  
    7575#include <synch/waitq.h>
    7676#include <synch/futex.h>
     77#include <synch/workqueue.h>
    7778#include <smp/smp_call.h>
    7879#include <arch/arch.h>
     
    249250
    250251        smp_call_init();
     252        workq_global_init();
    251253        clock_counter_init();
    252254        timeout_init();
  • kernel/generic/src/proc/scheduler.c

    r518dd43 r8a64e81e  
    5252#include <atomic.h>
    5353#include <synch/spinlock.h>
     54#include <synch/workqueue.h>
    5455#include <config.h>
    5556#include <context.h>
     
    126127static void after_thread_ran(void)
    127128{
     129        workq_after_thread_ran();
    128130        after_thread_ran_arch();
    129131}
  • kernel/generic/src/proc/thread.c

    r518dd43 r8a64e81e  
    4646#include <synch/spinlock.h>
    4747#include <synch/waitq.h>
     48#include <synch/workqueue.h>
    4849#include <cpu.h>
    4950#include <str.h>
     
    260261}
    261262
     263/** Invoked right before thread_ready() readies the thread. thread is locked. */
     264static void before_thread_is_ready(thread_t *thread)
     265{
     266        ASSERT(irq_spinlock_locked(&thread->lock));
     267        workq_before_thread_is_ready(thread);
     268}
     269
    262270/** Make thread ready
    263271 *
     
    273281        ASSERT(thread->state != Ready);
    274282
     283        before_thread_is_ready(thread);
     284       
    275285        int i = (thread->priority < RQ_COUNT - 1) ?
    276286            ++thread->priority : thread->priority;
     
    378388       
    379389        thread->task = task;
     390       
     391        thread->workq = NULL;
    380392       
    381393        thread->fpu_context_exists = false;
  • kernel/test/test.c

    r518dd43 r8a64e81e  
    5050#include <synch/semaphore1.def>
    5151#include <synch/semaphore2.def>
     52#include <synch/workqueue1.def>
     53#include <synch/workqueue2.def>
     54#include <synch/workqueue3.def>
    5255#include <print/print1.def>
    5356#include <print/print2.def>
  • kernel/test/test.h

    r518dd43 r8a64e81e  
    7676extern const char *test_thread1(void);
    7777extern const char *test_smpcall1(void);
     78extern const char *test_workqueue1(void);
     79extern const char *test_workqueue2(void);
     80extern const char *test_workqueue2stop(void);
     81extern const char *test_workqueue3(void);
     82extern const char *test_workqueue3quit(void);
     83
    7884
    7985extern test_t tests[];
Note: See TracChangeset for help on using the changeset viewer.