LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-23-2004, 08:56 AM   #1
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Why I like preemtible kernels.


I just decide to try something I haven't done in linux for a long time. We were having a discussion at work about solaris vs. linux thread management. Somebody was arguing that a forking program gone bad in solaris would bring the system to a halt while in linux it would eventually kill them all and the system would be fine. So I wrote a small program I call nastyfork to test this theory:
Code:
#include <sys/types.h>
#include <unistd.h>
#include <limits.h>

int main(void)
{
   unsigned long i;
   for (i=0;i<=LONG_MAX;i++)
   {
      if(!fork())
      {
         break;
      }
   }
   return 0;
}
When I ran this on the 2.4 kernel the same basic thing happen that happened in solaris, the machine became unusable. So I was bored this morning and I brought nastyfork back out and ran it on my 2.6.1 kernel with the preemtible kernel enabled. To my surprise it runs happily up to the point where linux says it can't fork anymore, and although my processor usage reads 100% and I can't run anything because "bash: fork: Resource temporarily unavailable" my GUI interface is still VERY responsive, which is a step in the right direction.

And yes... I am THAT bored.
 
Old 01-23-2004, 11:02 AM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
another good reason is that it forces (lazy)module writers to write re-entrant code.
 
Old 01-23-2004, 11:06 AM   #3
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892

Original Poster
Blog Entries: 1

Rep: Reputation: 67
Very good point.
 
Old 01-23-2004, 11:13 AM   #4
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
i'm running that code right now on 2.4.23-ck1 with the desktop low latency patches
that i don't really understand, but the system is plenty responsive. how long
should it take to die?

it takes about 10 seconds to get up to 14,000 something tasks, and then adds
no more. cpu usage says 100% as i'm typing this.

Last edited by whansard; 01-23-2004 at 11:25 AM.
 
Old 01-23-2004, 11:25 AM   #5
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892

Original Poster
Blog Entries: 1

Rep: Reputation: 67
The low latency patch might take care of it, I was running it on a very early 2.4 kernel when it made the system unresponsive.
 
Old 01-23-2004, 11:31 AM   #6
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
i was just testing it on a different kernel for you.

84 010-ckbase.diff.bz2 4 012-rl2dt.diff.bz2 4 014-vhz.diff.bz2
4 011-readlatency2.diff.bz2 8 013-j64.diff.bz2

those are the kernel patches i have added in.
 
Old 01-23-2004, 11:41 AM   #7
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
I tried this simpler forkbomb.c, which could be even a little nastier because it doesn't stop after LONG_MAX.
Code:
#include <unistd.h>

int main()
{
     for(;;) fork();
     return 0;
}
I tried it on the latest 2.4 kernel (2.4.24) without any patches, and it even made me use the power switch. On 2.6.1 I can type this post as if nothing is happening. "top" on another xterm doesn't update its display anymore though...
 
Old 01-23-2004, 12:00 PM   #8
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892

Original Poster
Blog Entries: 1

Rep: Reputation: 67
Ya, that is definitly nastier, the one I wrote might give the 2.4.24 kernel a chance or recover... but it will take a while.
 
Old 01-25-2004, 09:18 AM   #9
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
ive not done much testing but video capture seems to be rubbish in a preemptible 2.6.0 even in single user mode audio and video go out of sync almost immediatly where they dont in 2.4.22, but this could be due to new v4l/bttv stuff when i have time i'll test it properly.

btw i know 2.4.22 and 2.6.0 have security problems, and im not using them anymore
 
Old 01-25-2004, 10:08 AM   #10
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892

Original Poster
Blog Entries: 1

Rep: Reputation: 67
Ya, should be easy to get a 2.6.1 kernel with and without the peremptible part and see if it makes a difference. Perhaps the bttv modules weren't update..
 
Old 01-25-2004, 01:12 PM   #11
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
Quote:
Originally posted by Hko
I tried this simpler forkbomb.c, which could be even a little nastier because it doesn't stop after LONG_MAX.
Code:
#include <unistd.h>

int main()
{
     for(;;) fork();
     return 0;
}
I tried it on the latest 2.4 kernel (2.4.24) without any patches, and it even made me use the power switch. On 2.6.1 I can type this post as if nothing is happening. "top" on another xterm doesn't update its display anymore though...

i tried that one, and i couldn't start an tasks, and i couldn't really exit any either.
i exited x, and couldn't get a prompt back. i typed df, on a different terminal,
no response. i could suspend a task, but not end one. i hit reset after about
10 minutes.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Old Kernels blacksunshine Linux - Software 1 09-27-2004 10:23 PM
different kernels master Slackware 8 09-27-2004 03:27 PM
4 different kernels? ampex189 Linux - General 4 03-26-2004 02:16 AM
RH 8 kernels and their relation to 'stock' kernels psweetma Linux - Distributions 1 03-29-2003 10:46 PM
kernels watashiwaotaku7 General 2 12-26-2002 08:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration