Everything2
Near Matches
Ignore Exact
Full Text
Everything2

bottom half

created by Perdig

(idea) by Perdig (4 y) (print)   ?   (I like it!) Wed Jan 23 2002 at 15:28:42

Bottom halfs are a feature of the Linux Kernel (and probably of other kernels too) that mark some code to be executed later, making the system more responsive.

Whenever a hardware device issues a Interrupt, the kernel checks if there is a interrupt handler installed for it, and then, if its the case, it will run it. However, whenever the kernel is running the handler, no other proccess can run. Besides, the interrupt handler is non-preemptible, which means that no other code can take it over.

And whats the problem with that? The problem is that, if the interrupt handler is too big, the kernel will have to wait until it stops. That's pretty bad. (Imagine if, everytime you moved your mouse, the kernel could calculate a new mersenne prime and not let you do anything)

So, to take care of these problems, we have bottom halfs. Whenever a Interrupt is issued, the kernel calls the interrupt handler, that does only the critical job (like telling the hardware that it has acknowledged the interrupt or something like that). Then, it schedules a bottom half to do the dirty job. Whenever the kernel has some time, it runs the bottom half code.

For example, in kernel 2.2.x, we could have a bottom half called:

static void got_char(void *scancode);

And our IRC handler would do:

/* Define the bottom half */
static struct tq_struct task = {NULL, 0, got_char, &scancode};
/* Queue it */
queue_task(&task, &tq_immediate);
/* Mark as a BH for immediate execution (ie, ASAP) */
mark_bh(IMMEDIATE_BH);

In the 2.4.x kernel serie, bottom halfs were replaced by softirqs and tasklets.


Disclaimer: I'm still learning kernel programming... the above information can be wrong... if it is, please correct me!

printable version
chaos

tasklet Aiee, killing interrupt handler! Poor Man's LIRC kernel
disclaimer Kwyjibo struct bottom posting
Linux 2.4 Programming interrupt Linux kernel
Soundscan
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Things you could have written:
Reflections, unacknowledged
The four C's of diamond grading
Theodore Roethke
Zeno's Paradox as proof of a finite universe
Five Years to the Day...
Christian fundamentalists will end the world through fear and suffering
anger management
Call me a lady and I will growl at you
I was a College Jeopardy! champion, Part 2
Patton's Speech to the Third Army
Judging women by their books
A Blather of Paradoxes
Calypso
New Writeups
Aerobe
Watch out for falling meat(poetry)
C-Dawg
Beelzebub has a devil put aside for me(fiction)
Pavlovna
My Better Half(fiction)
kanoodle
Molson muscle(essay)
aneurin
You pays your money and you takes your choice(idea)
shaogo
July 20, 2008(log)
Glowing Fish
Tualatin River(place)
The Jacket
Words of Advice(idea)
John_Fox
Good Intentions Gone Wrong(person)
Heitah
Posthumous Oscar(thing)
ignis_glaciesque
University of South Florida(place)
ignis_glaciesque
Flogstaskriket(idea)
liveforever
Caesar's last breath(idea)
dagnyswaggart
she wants to believe(personal)
antigravpussy
he doesn't know, but her eyes widen too far(thing)
This page courtesy of The Everything Development Company