Main Page | Modules | Class List | File List | Class Members | File Members | Related Pages

Deferred Activities
[Linux DDE Common]

This module emulates deferred activities at interrupt level inside the Linux kernel. More...

Softirqs

This is from include/linux/interrupt.h

Softirqs are multithreaded, not serialized BH-like activities. Several softirqs may run on several CPUs simultaneously - no matter if they are of the same type.

Properties:

  • If raise_softirq() is called, then softirq is guarenteed to be executed on this CPU.
  • On schedule() do_softirq() is called if any softirq is active on this CPU.
  • Softirqs are not serialized in any way.

Linux (2.4.20) has only 4 softirqs:

  • HI_SOFTIRQ
  • NET_TX_SOFTIRQ and NET_RX_SOFTIRQ
  • TASKLET_SOFTIRQ

Relevant for Linux DDE are for now only the first and the latter - NET_* softirqs allow transparent mutli-threading in Linux' network code. HI_SOFTIRQ is for high priority bottom halves as old-style BHs and sound related drivers. It triggers execution of tasklet_hi_action(). TASKLET_SOFTIRQ runs lower priority bottom halves (e.g. in the console subsystem). It triggers execution of tasklet_action().

Todo:
only the implementation of tasklets is done in Linux DDE


void raise_softirq (int nr)
 Raise Softirq.


Tasklets

This is from kernel/%softirq.c and include/linux/interrupt.h)

Tasklets are the multithreaded analogue of BHs.

Main feature differing them of generic softirqs: one tasklet is running only on one CPU simultaneously.

Main feature differing them of BHs: different tasklets may be run simultaneously on different CPUs.

Properties:

  • If tasklet_schedule() is called, then tasklet is guaranteed to be executed on some cpu at least once after this.
  • If the tasklet is already scheduled, but its excecution is still not started, it will be executed only once.
  • If this tasklet is already running on another CPU (or schedule() is called from tasklet itself), it is rescheduled for later.
  • Tasklet is strictly serialized wrt itself, but not wrt another tasklets. If client needs some intertask synchronization, he makes it with spinlocks.

  • these functions are thread-safe
  • no assumption how much softirq threads
  • one driver seldom uses more than 1 tasklet/bh therefore 1 tasklet thread is enough ?!

Tasklet lists are CPU local in Linux and so tasklet related synchonization is. This is not in Linux DDE - local_irq_disable()/enable() is not sufficient. We use our cli()/sti() implementation.

Todo:
Rethink tasklet_vec[1] for more than 1 softirq thread; so NR_CPUS will become NR_SOFTIRQ_THREADS later


void tasklet_init (struct tasklet_struct *t, void(*func)(unsigned long), unsigned long data)
 Tasklet Initialization.

void tasklet_kill (struct tasklet_struct *t)
 Tasklet Termination.

void tasklet_schedule (struct tasklet_struct *t)
 Schedule dedicated tasklet.

void tasklet_hi_schedule (struct tasklet_struct *t)
 Schedule dedicated high-priority tasklet.


Old-style Bottom Halves and Task Queues

This is from kernel/%softirq.c

All bottom halves run as one tasklet so no two bottom halves can run simultaneously.

Todo:
Implement this if any useful driver needs it.

encapsulate tqueue_lock like tasklet_vec providing proper interface



void __run_task_queue (task_queue *list)
 Task Queue Execution.

spinlock_t tqueue_lock = SPIN_LOCK_UNLOCKED
 protects tqueue list operation (from kernel/timer.c)


Functions

int l4dde_softirq_init ()
 Initalize Softirq Thread(s).


Detailed Description

This module emulates deferred activities at interrupt level inside the Linux kernel.

Deferred activities in Linux can be old-style bottom halves, new-style tasklets and softirqs.

Requirements: (additionally to Global Requirements)

Configuration:


Function Documentation

void __run_task_queue task_queue *  list  ) 
 

Task Queue Execution.

Runs _all_ tasks currently in task queue list.

Definition at line 390 of file softirq.c.

References tqueue_lock.

int l4dde_softirq_init  ) 
 

Initalize Softirq Thread(s).

Returns:
0 on success; negative error code otherwise
All threads for deferred activities are created on initialization.

Todo:
configuration with more (than 1) threads

Definition at line 465 of file softirq.c.

References _initialized, and dde_softirq_thread().

void raise_softirq int  nr  ) 
 

Raise Softirq.

Parameters:
nr one of (HI_SOFTIRQ, NET_TX_SOFTIRQ, NET_RX_SOFTIRQ, TASKLET_SOFTIRQ)
Grab global lock and raise softirq for a dedicated handler.

Definition at line 125 of file softirq.c.

References __cpu_raise_softirq().

void tasklet_hi_schedule struct tasklet_struct *  t  ) 
 

Schedule dedicated high-priority tasklet.

Parameters:
t high-priority tasklet to be scheduled for execution
If tasklet is not already scheduled, grab global lock, enqueue as first in global list, and raise softirq.

Definition at line 352 of file softirq.c.

References __cpu_raise_softirq(), and tasklet_hi_vec.

void tasklet_init struct tasklet_struct *  t,
void(*  func)(unsigned long),
unsigned long  data
 

Tasklet Initialization.

Parameters:
t tasklet struct that should be initialized
func task of this deferred activity (handler function)
data data cookie passed to handler

Definition at line 273 of file softirq.c.

void tasklet_kill struct tasklet_struct *  t  ) 
 

Tasklet Termination.

Parameters:
t tasklet to be killed

Definition at line 287 of file softirq.c.

References SCHED_YIELD_TO, and schedule().

void tasklet_schedule struct tasklet_struct *  t  ) 
 

Schedule dedicated tasklet.

Parameters:
t tasklet to be scheduled for execution
If tasklet is not already scheduled, grab global lock, enqueue as first in global list, and raise softirq.

Definition at line 327 of file softirq.c.

References __cpu_raise_softirq(), and tasklet_vec.


Linux DDE, written by Christian Helmuth  © 2003 Technische Universitaet Dresden