From mint-bounce@lists.fishpool.fi Thu Mar 3 13:19:15 2005 X-Original-To: fnaumann@mail.boerde.de Delivered-To: fnaumann@mail.boerde.de Message-ID: <422700A2.2020602@yahoo.fr> Date: Thu, 03 Mar 2005 13:18:42 +0100 From: Zorro User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: fr, en MIME-Version: 1.0 To: mintlist Subject: Re: [MiNT] How to get CPU time? References: <42263210.1090405@yahoo.fr> <42263E21.7070207@yahoo.fr> <42264424.8070702@yahoo.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-To: mint-bounce@lists.fishpool.fi X-original-sender: zorro270@yahoo.fr 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=3.6 tagged_above=-50.5 required=5.0 tests=AWL, BAYES_00, FROM_ENDS_IN_NUMS, RCVD_IN_SORBS X-Spam-Level: *** Hi! > It should be like on Linux. If not it's a bug or it's missing. The idea > was to simplify porting of Linux apps that use /proc. You just need to > replace /proc with /kern (as already mentioned we couldn't use /proc as > this was already in use under FreeMiNT; otherwise we had for sure > choosen /proc :-)). Ok, but something is strange, maybe a MiNT's bug.. look at my code: ------------------------ int16 get_cpu_usage( void) { static int32 pre_used = 0, pre_total = 0; int16 usage = 0, factor = 100; int32 cpu, nice, system, idle, used = 0, total = 0; FILE *fp; if ( !( fp = fopen("U:/kern/stat", "r"))) return usage; fscanf( fp, "%*s %ld %ld %ld %ld", &cpu, &nice, &system, &idle); fclose(fp); used = cpu + system + nice; total = used + idle; /* calc CPU usage */ if( total - pre_total > 0) usage = ( int16)(( factor * ( double)( used - pre_used)) / (double)( total - pre_total)); if( usage < 0) usage = 0; pre_used = used; pre_total = total; return usage; } ----------------------- It works on linux ( of course with /proc/stat) but on MiNT, I must set the 'factor' variable at 20 to have the good CPU load in percent. ( ??) It seems that the idle's value is 5 times superior that it should be. Nevertheless, it works like a charm, thanks again for your help ! > We also have some FreMiNT specific extension like the cookijar list, > sysdir and such things. Ideas and improvements welcome. Well, the real lacks aren't in MiNT itself but in the Mintlib. I dream at a shareable mintlib because actually, deal with threads or externals libraries like SLB or LDG using libc functions is impossible :/ But that's another story... >> 2) This data are updated every second or faster( every 'clock tick')? > The data are updated if you read it :-) Ask and MiNT gives :) >> MiNT is really a "strange" Unix system.. some stuffs are like in Linux >> and others like in BSD :) > Don't know what you mean. BSD and Linux are both Unix systems. I mean that, for example, MiNT is a monolithic kernel with external extentions like linux but it's provide a BSD socket, etc etc.. It's a "mix" of Linux and BSD. Ciao, Zorro