From mint-bounce@lists.fishpool.fi Tue Nov 30 09:20:51 2004 X-Original-To: fnaumann@mail.boerde.de Delivered-To: fnaumann@mail.boerde.de Message-ID: <41AC2CD6.6030000@gabo.pl> Date: Tue, 30 Nov 2004 09:18:30 +0100 From: Adam Klobukowski User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: mint@fishpool.com Subject: [MiNT] Ammount of file descriptors per process Content-Type: multipart/mixed; boundary="------------000506070909000601070701" X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-To: mint-bounce@lists.fishpool.fi X-original-sender: atari@gabo.pl Precedence: bulk List-help: List-unsubscribe: List-Id: X-List-ID: X-Virus-Scanned: by amavisd-new at relay.boerde.de X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on relay.boerde.de X-Spam-Status: No, hits=-1.0 tagged_above=-50.5 required=3.8 tests=BAYES_00 X-Spam-Level: This is a multi-part message in MIME format. --------------000506070909000601070701 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Hell I've written a small test program. Small one, so I attached it to this mail. It opens as much as possible files (at once) depending on information he can get. The aim was to test both MiNTLib and the kernel. There are 3 tests in this file: 1. Opening files using library call fopen(), the maximum ammount of files it tries to open is taken from FOPEN_MAX library constant. 2. Opening files using library call open(), the maximum ammount of files it tries to open is taken from RLIMIT_NOFILE library constant. 3. Opening (creating) files using system call Fcreate(), the maximum ammount of files it tries to open is taken from Sysconf(SYS_MAXFILES) system call. And now the tests result. Ad 1. FOPEN_MAX is 255, but the test fails whe there are 26 files opened. Ad 2. RLIMIT_NOFILE is 6. Test passes. Ad 3. Sysconf(SYS_MAXFILES) returns 32. Test fails after opening 26 files. Conclusions: At the beginning _process_that_does_nothing_ has 9 file descriptors opened (according to /kerm/*/fd). If 32 is a maximum ammount of file descriptors per process, then 26 + 9 = 35, so there is something wrong here. On the other hand FOPEN_MAX is wrong, and can lead to hard to trace errors in ported software. Or, if I'm wrong please correct me. For everyone that would like to try it at home: test program assumes that there is a 'tmp' directory in CWD, wher it does its job. I take no other responsibility. -- Semper Fidelis Adam Klobukowski atari@gabo.pl --------------000506070909000601070701 Content-Type: text/plain; name="files.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="files.c" /* * FreeMiNT Test Suite * * 1000000 Opened files test */ #include #include #include #include #include #include #include #include #include void remove_files(int count) { int a, ret; char fname[FILENAME_MAX]; for (a=0;a 0) printf ("succes!\n"); else { printf("failed! return value: %d strerror(return value): %s\n", f[a], strerror(f[a])); break; } fflush(NULL); } for (b=0;b