[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: #define NR_TASKS ??

On Wednesday 23 May 2001 13:00, Viral wrote:
> mproc (mps and mtop for the mosix multicomputer) uses NR_TASKS.
> However I couldn't find it in the include files for the 2.4.4 kernel.
> It looks in linux/tasks.h for
> #define NR_TASKS
> For the time being I defined it to be 1024 (hoping thats large and safe)
> but whats the deal with NR_TASKS in 2.4.4 ?
> Or its the case that I have corrupted kernel sources. ;-)

Your kernel source is not corrupted, things are being done differently in 

Here's some code from fork.c:
max_threads = mempages / (THREAD_SIZE/PAGE_SIZE) / 2;

On Intel THREAD_SIZE is 2*PAGE_SIZE, on some architectures it's 4*PAGE_SIZE.

So for my P3 laptop with 256M of RAM I'll have something like 16000 processes 

I have attached a program I wrote to test this.  After about 4300 processes 
my machine started running extremely slow (all processes were running 
sleep(3600) so they weren't using any CPU time) and the hard drive light was 
off (there had been paging but this wasn't the cause of the problem).  The 
machine essentially stopped for around 10 seconds at a time with the hard 
drive light off, sometimes even the mouse cursor stopped moving.

In fact the performance became so bad that I have decided to CC this message 
to Rik van Riel as I think it may indicate a deficiency in the tuning of the 
kernel.  This program compiles to 5K of ELF binary, I don't think that 4000 
copies of it should kill my machine so badly.

Back to the topic of the number of threads for Beowulf, compiling it for a 
number >1024 might be a bad idea.  On my machine it was at about 1500 
processes that things started to go badly.

http://www.coker.com.au/bonnie++/     Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/       Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/     My home page
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>

int main()
  pid_t p[100000];
  for(int i = 1; ; i++)
    pid_t rc = fork();
    if(rc == -1)
      for(i--; i > 0; i--)
        if(p[i] > 0)
          kill(p[i], 9);
    if(rc == 0)
    else if(rc > 0)
      printf("%d:%d\n", i, rc);
      p[i] = rc;
  return 0;

Reply to: