A while back on the darwin-kernel list, someone mentioned wanting to be able to dynamically increment the max number of processes per uid. Currently, Darwin has the value hard coded to be 100. I have modified the kernel so that you can now dynamically change the maximum number of processes per uid during runtime. Here is the rundown: There was already a variable in the source code, called maxprocperuid. It looks like this feature was either already in the kernel once before, or is planned for in the future. However, as it stands, the variable is currently unused. What I have done is link this variable to a sysctl so that you can do a sysctl -w kern.maxprocperuid=### to set it during runtime. I then replaced references to CHILD_MAX, with references to maxprocperuid and added some sanity checking. I have put maxprocperuid into the same scope as maxproc (Global). ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------ My changes are made in: bsd/sys/proc.h bsd/conf/param.c bsd/kern/kern_fork.c bsd/kern/kern_resource.c bsd/kern/kern_sysctl.c What changed: bsd/sys/proc.h 1 Set maxprocperuid's scope to be global ( The same scope as maxproc) bsd/conf/param.c 1 Declared maxprocperuid, and set it to CHILD_MAX so that the default is still 100 on bootup bsd/kern/kern_fork.c 1 Check the maxprocperuid value on each call to fork1() and vfork(), if process count exceeds it, set the processes soft limit to be equal to maxprocperuid and return EAGAIN bsd/kern/kern_resource.c 1 Check the processes hard limit and set it to maxprocperuid if it exceeds maxprocperuid bsd/kern/kern_sysctl.c 1 Tie maxprocperuid to a sysctl, so that the root user may set the value and read the value via the sysctl interface. (ie via sysctl kern.maxprocperuid) 2 Added sanity checking so that when maxproc or maxprocperuid is changed, the kernel checks to be sure that maxprocperuid is less than maxproc. If not, it sets maxprocperuid to maxproc - 100 ------------------------------------------------------------------------ ------------------------------------------------------------------------ Getting the changes: 1) Go to my personal website and Download http://www.hybridmachine.com/darwin_maxprocperuid.tgz 2) Download the 10.2.5 Darwin sourcecode from Apple and untar it 3) cd into xnu 4) copy the darwin_maxprocperuid.tgz file into the current directory 5) tar xvzf darwin_maxprocperuid.tgz 6) Read the ABOUT_darwin_maxprocperuid.txt file <-- Tells you how to use the new feature 7) Read the README and build the kernel 8) Read the "Booting alternate kernels" text file that I have included in the .tgz file 9) Boot the alternate kernel and enjoy If you are feeling lazy, you can use the pre-compiled kernel included in the darwin_maxprocperuid.tgz file. Simply do step 8, copy the mach_kernel.new to /, and reboot I recommend building your own kernel, however. ------------------------------------------------------------------------ ------------------------------------------------------------------------ These changes are licensed under the APSL, and while I hope they are useful I make NO WARRANTY regarding them. This is my first foray into kernel hacking, feedback and constructive criticism are very welcome! _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.
participants (1)
-
Brian Tabone