Linux-Development-Apps Digest #331, Volume #7 Thu, 12 Apr 01 16:13:17 EDT Contents: Is there any API for monitoring system resources(CPU utilization, free memory....)? ("Àӹο") Re: Is there any API for monitoring system resources(CPU utilization, free memory....)? ("Zoran Cutura") Re: Help with pthreads on linux (John Prokopek) pthread_join not returning (John Prokopek) Re: pthread_join not returning ("Zoran Cutura") Detecting idle time on a loopback file system (Kenneth P. Turvey) Re: How to detect memory leaks ? (Chris) Re: How to detect memory leaks ? (Jonathan Magid) Re: Public Domain CODEC (hac) Re: static link and file size (Chris) Re: Is there any API for monitoring system resources(CPU utilization, (Jan Atle Ramsli) ioctl help me ("tpi") Re: deecting a new file without scanning the directories ([EMAIL PROTECTED]) Re: Is there any API for monitoring system resources(CPU utilization, free memory....)? (Nate Eldredge) Re: Is there any API for monitoring system resources(CPU utilization, (Paul D. Boyle) Re: How many times Linux Thread can be executed? (Philip Armstrong) Re: compile error (Jan Atle Ramsli) Re: How to detect memory leaks ? (Mike Romberg) Re: Public Domain CODEC ("Phil Frisbie, Jr.") How to hook into the _init for a .so file ("Bill Medland") ---------------------------------------------------------------------------- From: "Àӹο" <[EMAIL PROTECTED]> Subject: Is there any API for monitoring system resources(CPU utilization, free memory....)? Date: Thu, 12 Apr 2001 22:28:46 +0900 Hi, there! I wonder whether there is any programing library with which we can monitor system resources(CPU utilization, free memory...)? If it isn't, how can I do that? Thanks in advance. ------------------------------ From: "Zoran Cutura" <[EMAIL PROTECTED]> Subject: Re: Is there any API for monitoring system resources(CPU utilization, free memory....)? Date: Thu, 12 Apr 2001 15:42:09 +0200 Reply-To: [EMAIL PROTECTED] Once upon a while "Àӹο" <[EMAIL PROTECTED]> wrote: > Hi, there! > > I wonder whether there is any programing library with which we > can monitor system resources(CPU utilization, free memory...)? man getrusage -- Z ([EMAIL PROTECTED]) "LISP is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days." -- Eric S. Raymond ------------------------------ From: John Prokopek <[EMAIL PROTECTED]> Subject: Re: Help with pthreads on linux Date: Thu, 12 Apr 2001 09:49:35 -0400 I assume that you have tried a simple thread app as a test. I am just learning pthreads on a redhat 7.0 system and have no problem regarding the current user. what kind of problem are you having? will the app run and just fail on the thread call or is it that the app won't run at all? "Heath R. Foster" wrote: > > The problem is that when a build an application that comtains pthreads > it won't run unless I log in as root. On solaris and hpux I have not > problem. Is there a way the create pthreads on linux with out being > root? -- John D. Prokopek [EMAIL PROTECTED] ------------------------------ From: John Prokopek <[EMAIL PROTECTED]> Subject: pthread_join not returning Date: Thu, 12 Apr 2001 10:00:03 -0400 I am just learning rthreads on a redhat 7 system and am having problems with the pthread_join call. For some strange and bizarre reason it seems that the app stops at the join. Right now the thread does nothing but count within a loop. the following is the code snippet. thanks for the help void * do_one_thing(void * pv) { int * counter = (int*)pv; int i, j, x; for( i = 0; i < 10; i++) { printf("doing one thing\n"); for( j = 0; j < 1000000; j++) { x = x+1; } (*counter)++; } return NULL; } int main(int argc, char ** argv) { int r1; pthread_t thread1; pthread_create(&thread1, NULL, do_one_thing, (void*)&r1); pthread_join(thread1, NULL); printf("done\n"); return 0; } -- John D. Prokopek [EMAIL PROTECTED] ------------------------------ From: "Zoran Cutura" <[EMAIL PROTECTED]> Subject: Re: pthread_join not returning Date: Thu, 12 Apr 2001 16:29:35 +0200 Reply-To: [EMAIL PROTECTED] Once upon a while "John Prokopek" <[EMAIL PROTECTED]> wrote: > I am just learning rthreads on a redhat 7 system and am having > problems with > the pthread_join call. For some strange and bizarre reason it > seems that the app > stops at the join. Right now the thread does nothing but count > within a loop. > the following is the code snippet. > > thanks for the help > > > > void * do_one_thing(void * pv) > { > int * counter = (int*)pv; > int i, j, x; > > for( i = 0; i < 10; i++) > { > printf("doing one thing\n"); > for( j = 0; j < 1000000; j++) > { > x = x+1; > } > (*counter)++; > > } > return NULL; > } > > > int main(int argc, char ** argv) { > int r1; > pthread_t thread1; > > pthread_create(&thread1, NULL, do_one_thing, (void*)&r1); > > pthread_join(thread1, NULL); > > printf("done\n"); > > return 0; > > } If you read a bit harder in what ever text you have about pthreads, you would have recognized that: (from man pthread_join) pthread_join suspends the execution of the calling thread until the thread identified by th terminates, either by calling pthread_exit(3) or by being cancelled. This says, that it is not enough to have the do_one_thing function return or stop execution, but it needs to call pthread_exit (which is documented in section 3 of man). -- Z ([EMAIL PROTECTED]) "LISP is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days." -- Eric S. Raymond ------------------------------ From: [EMAIL PROTECTED] (Kenneth P. Turvey) Subject: Detecting idle time on a loopback file system Date: Thu, 12 Apr 2001 07:09:53 -0500 I was recently comparing methods of encrypting partitions. The two methods that really stand out include cfs, the cryptographic file system, and the loopback file system (using encryption with this file system is only supported by the international kernel to avoid problems with the tyrannical export laws in the US). I found cfs to kludgey and unsatisfying in comparison to the loopback file system. Its real strength is that is it portable across multiple platforms. It did have one feature that I did like however. When attaching to a cryptographic file system the user could specify a timeout. After the specified amount of idle time on the file system it would be detached. It seems like this would be very easy to implement using the loopback file system, but there are two problems. 1) How do you detect the last time there was activity on the file system? 2) How is it unmounted if it is still the pwd for an active process? It seems the use time of the loopback file is not updated when a read() or write() call is made on the file system. Any help would be appreciated. -- Kenneth P. Turvey <[EMAIL PROTECTED]> ======================================================== We must all hang together, or most assuredly, we will all hang separately. -- Benjamin Franklin ------------------------------ From: Chris <[EMAIL PROTECTED]> Subject: Re: How to detect memory leaks ? Date: Thu, 12 Apr 2001 15:44:02 +0100 Friedrich Dominicus wrote: > > "Hubert" <[EMAIL PROTECTED]> writes: > > > "Chris" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED]... > > > Hubert wrote: > > > > > > > > I am looking for a tool that helps me detecting memory problems like > > memory > > > > leaks. > > > > Can anybody recommand a tool or library for Linux and C++? > > > > > > Others will point you at various ways to do this, I > > > expect, but there is a simple C++ approach using macros > > > and placement new: (note that this code is not very > > > tested ;) ) > > Can't see why one should not use existing tools. Two reasons: Firstly, this is an extremely simple programming exercise, certainly smaller than installing and learning a new tool. It was also instructive to write. Secondly, it is completely portable (at least, to any system where C++ works). -- Chris Lightfoot -- chris at ex dash parrot dot com -- www.ex-parrot.com/~chris/ ``I have a sneaking sympathy for Belgium, as a land where, by accident of geography, too often other people have chosen to hold their wars.'' (Alan Follett) ------------------------------ From: [EMAIL PROTECTED] (Jonathan Magid) Subject: Re: How to detect memory leaks ? Date: 12 Apr 2001 10:06:30 -0400 In article <9b48vc$irn$[EMAIL PROTECTED]>, Hubert <[EMAIL PROTECTED]> wrote: > >You can't see why? Either did I, but now I can. > >- ElectricFence does not help detecting leaks. >- tried ccmalloc -- then application produces SIGSEGV >- tried LeakTrace -- SIGSEGV >- tried SmartHeap for Linux, a good product which I also use on NT. This did >not work because another third party component I use has its own memory >mangament -- SIGSEGV > >Without these tools my application runs fine. >I would be positively suprised if I'd find a usable tool to detect memory >problems! You're running them. They are finding memory errors for you- You have other problems than leaks- you're misusing allocated memory somewhere. I only have experience ElectricFence, so I'll concentrate on that. Here's a selection from the efence man page: Electric Fence uses the virtual memory hardware of your computer to place an inaccessible memory page immediately after (or before, at the user's option) each memory allo cation. When software reads or writes this inaccessible page, the hardware issues a segmentation fault, stopping the program at the offending instruction. It is then triv ial to find the erroneous statement using your favorite debugger. In a similar manner, memory that has been released by free() is made inaccessible, and any code that touches it will get a segmentation fault. So, when efence segfaults, it's telling you that you've accessed memory that is either: not allocated to you, beyond the bounds of allocated memory, or has been freed already. To find out where the problem was, use gdb: gdb program core gdb> bt If you've compiled your code with debugging on, this will give you a frame trace of functions called in your code. You can move up or down amongst the frames by using "up" and "down" and look at the code surrounding it with "list". For more info on gdb try "info gdb". Btw, another memory debugger that's been useful for me is yamd: http://www3.hmc.edu/~neldredge/yamd/ cheers, jem. -- Unix Jack of All Trades Email: jem@sunsite^H^H^H^H^H^H^Hmetalab^H^H^H^H^H^H^Hibiblio.org ------------------------------ From: hac <[EMAIL PROTECTED]> Subject: Re: Public Domain CODEC Date: Thu, 12 Apr 2001 14:50:43 GMT "Chris M. Moore" wrote: > > On Wed, 11 Apr 2001 12:45:05 -0400, "Matrixx Entertainment" > <[EMAIL PROTECTED]> wrote: > > >We are specifically talking about DOWNLOADING > >movies . . . NOT *streaming* them at this time. > > Err, so what's wrong with MPEG1 then? > Patents. -- Howard Christeller Irvine, CA [EMAIL PROTECTED] ------------------------------ From: Chris <[EMAIL PROTECTED]> Subject: Re: static link and file size Date: Thu, 12 Apr 2001 15:59:22 +0100 "Stanislav V. Mekhanoshin" wrote: > > And also what will happen if I'll additionaly distribute an ELF object file > so that users could link it by themselfs even if the program linked by me is > not working? Does this have any sence? You could distribute the .o files and have users link them. -- Chris Lightfoot -- chris at ex dash parrot dot com -- www.ex-parrot.com/~chris/ ``I won't let you in until you explain the ending of the movie.'' (unknown US immigration officer, to Arthur C. Clarke, 1969) ------------------------------ Date: Thu, 12 Apr 2001 18:42:31 +0200 From: Jan Atle Ramsli <[EMAIL PROTECTED]> Subject: Re: Is there any API for monitoring system resources(CPU utilization, "Àӹο" wrote: > > Hi, there! > > I wonder whether there is any programing library with which we can monitor > system resources(CPU utilization, free memory...)? > If it isn't, how can I do that? You may find that some of the information is available in the /proc directory. If it is not available there, I would think that an API library would not be implemented, either. I think the chances of a system supporting an API but NOT supporting /proc filesystem are quite slim, so you must decide on whether you want to rely on /proc filesystem. If you do, then 'normal' file operations can be used. Atle ------------------------------ From: "tpi" <[EMAIL PROTECTED]> Subject: ioctl help me Date: Thu, 12 Apr 2001 17:51:26 +0200 anyone can help me? i need a good faq about this function ( ioctl) and good faq about all parameters ( second parameters , TIOCSTI etc.. ) ------------------------------ From: [EMAIL PROTECTED] Subject: Re: deecting a new file without scanning the directories Date: Thu, 12 Apr 2001 16:13:18 GMT Pavel Hofman <[EMAIL PROTECTED]> wrote: : I am wondering if there is a way to detect a new file or directory : without having to regularly scan the entire directory structure. What about writing a module to intercept the open syscall, which would check to see if this is a creation or merely an opening of an existing file, and would somehow alert you if it was the former? -- Jeff Gentry [EMAIL PROTECTED] [EMAIL PROTECTED] SEX DRUGS UNIX ------------------------------ From: Nate Eldredge <[EMAIL PROTECTED]> Subject: Re: Is there any API for monitoring system resources(CPU utilization, free memory....)? Date: 12 Apr 2001 09:33:35 -0700 "Àӹο" <[EMAIL PROTECTED]> writes: > Hi, there! > > I wonder whether there is any programing library with which we can monitor > system resources(CPU utilization, free memory...)? You might check out the libgtop library. -- Nate Eldredge [EMAIL PROTECTED] ------------------------------ From: [EMAIL PROTECTED] (Paul D. Boyle) Subject: Re: Is there any API for monitoring system resources(CPU utilization, Date: 12 Apr 2001 17:10:52 GMT Jan Atle Ramsli ([EMAIL PROTECTED]) wrote: : "Àӹο" wrote: : > : > Hi, there! : > : > I wonder whether there is any programing library with which we can monitor : > system resources(CPU utilization, free memory...)? : > If it isn't, how can I do that? : You may find that some of the information is available in the /proc : directory. : If it is not available there, I would think that an API library would : not be implemented, either. You can try reading the man page for getrusage() and see if that gives you the information you are seeking. Paul -- Paul D. Boyle [EMAIL PROTECTED] North Carolina State University http://laue.chem.ncsu.edu/web/xray.welcome.html ------------------------------ From: [EMAIL PROTECTED] (Philip Armstrong) Subject: Re: How many times Linux Thread can be executed? Date: 12 Apr 2001 10:25:37 +0100 In article <[EMAIL PROTECTED]>, Juyoung Park <[EMAIL PROTECTED]> wrote: >I'm so curious why my simple thread program hangs up after 1018th >execution. I read the man pages but cannot find anything about this >situation. Please let me know where the critical point I never have >catched. > while(1) > { > pthread_create(&mythread, NULL, (void*)timeout, NULL); >usleep(100000); > } Oh dear. Can we say forkbomb? :) I suspect you're creating more threads than is allowed by the underlying system. Phil -- http://www.kantaka.co.uk/ .oOo. public key: http://www.kantaka.co.uk/gpg.txt ------------------------------ Date: Thu, 12 Apr 2001 20:59:05 +0200 From: Jan Atle Ramsli <[EMAIL PROTECTED]> Subject: Re: compile error "T. Relyea" wrote: > > I've gone through the KPackage utility, and have installed just about every > library and development file I could find (that made sense), but still the > same error. When I installed Mandrake 7.2, I selected the development > option, so I would assume that everything needed would be included. Someone who knows Mandrake-Linux should answer this, I only know that I have had problems when mixing Mandrake with other distros, like RedHat. I think they put stuff in weird places. If you check the configure.in file, you can sprinkle it with small 'echo ' statements to see what is happening, and why it says you can't compile. Maybe it is just a matter of a header file or something ...? I also know that some symlinks can cause problems, in /usr/include/ Atle ------------------------------ From: Mike Romberg <[EMAIL PROTECTED]> Subject: Re: How to detect memory leaks ? Date: 12 Apr 2001 12:01:31 -0600 >>>>> " " == Hubert <[EMAIL PROTECTED]> writes: [snip] > Without these tools my application runs fine. I would be > positively suprised if I'd find a usable tool to detect memory > problems! I've recently started to use mpatrol (http://www.cbmamiga.demon.co.uk/mpatrol/) which seems to work ok. Mike Romberg ------------------------------ From: "Phil Frisbie, Jr." <[EMAIL PROTECTED]> Subject: Re: Public Domain CODEC Date: Thu, 12 Apr 2001 18:52:10 GMT There are no patent problems with MPEG 4. All contributors to MPEG 4 agree you can use the reference code for ANY MPEG 4 application. hac wrote: > > "Chris M. Moore" wrote: > > > > On Wed, 11 Apr 2001 12:45:05 -0400, "Matrixx Entertainment" > > <[EMAIL PROTECTED]> wrote: > > > > >We are specifically talking about DOWNLOADING > > >movies . . . NOT *streaming* them at this time. > > > > Err, so what's wrong with MPEG1 then? > > > Patents. Phil Frisbie, Jr. Lead Developer, Hawk Software http://www.hawksoft.com ------------------------------ From: "Bill Medland" <[EMAIL PROTECTED]> Subject: How to hook into the _init for a .so file Date: Thu, 12 Apr 2001 19:45:45 GMT Sorry; I see that this has been addressed a bit but I don't understand. I am going to want to execute some code when a shared library is loaded and unloaded. I was advised to "do the appropriate compiler magic to arrange for your own function to be called by the library _init() routine (which does other stuff as well, don't try and just replace it wholesale)." >From the discussions in this newsgroup it looks like most people just use -nostartfiles, but that means replacing the _init (and so losing the existing functionality). Martin Kahlert spotted that issue and asked. The reply pointed him at the redhat source code. Looking at the source code for glibc-2.1 (init-first.c and soinit.c) doesn't really help me much. Is it possible to hook into the _init and _fini in some way or are we supposed to reimplement them ourselves in all their gory detail? Bill ------------------------------ ** FOR YOUR REFERENCE ** The service address, to which questions about the list itself and requests to be added to or deleted from it should be directed, is: Internet: [EMAIL PROTECTED] You can send mail to the entire list by posting to the comp.os.linux.development.apps newsgroup. Linux may be obtained via one of these FTP sites: ftp.funet.fi pub/Linux tsx-11.mit.edu pub/linux sunsite.unc.edu pub/Linux End of Linux-Development-Apps Digest ******************************