Linux-Development-Sys Digest #471
Linux-Development-Sys Digest #471, Volume #8 Wed, 7 Feb 01 05:13:15 EST Contents: Re: recursive mutex implementation (Kaz Kylheku) Re: reliable coredump under Linux? ("Gene Soudlenkov") Re: recursive mutex implementation (Kaz Kylheku) does 2.4 kernel need 2.4 initrd? (Eric Taylor) Re: Module Programming Question (Unresolved symbol printk) ([EMAIL PROTECTED]) Re: sleeping inside the kernel (sleep_on ; schedule_timeout) ([EMAIL PROTECTED]) EXPORT Kernel Symbol ([EMAIL PROTECTED]) Re: EXPORT Kernel Symbol ("Gene Soudlenkov") Sendmail problem... ("avi") Re: EXPORT Kernel Symbol ([EMAIL PROTECTED]) Re: Isn't ReiserFS in 2.4.1 (Marc SCHAEFER) EXPORT Kernel Symbol for my own Kernel Function ([EMAIL PROTECTED]) Re: does 2.4 kernel need 2.4 initrd? (Villy Kruse) Re: Module Programming Question (Unresolved symbol printk) (Josef Moellers) Re: can Linux be secure? (Kasper Dupont) Re: Module Programming Question (Unresolved symbol printk) (Kasper Dupont) Re: does 2.4 kernel need 2.4 initrd? (Anders Larsen) Re: does 2.4 kernel need 2.4 initrd? (Eric Taylor) From: [EMAIL PROTECTED] (Kaz Kylheku) Subject: Re: recursive mutex implementation Reply-To: [EMAIL PROTECTED] Date: Wed, 07 Feb 2001 00:09:24 GMT On Tue, 06 Feb 2001 22:31:46 GMT, Daniele Pallastrelli [EMAIL PROTECTED] wrote: Hi all, I need to implement a my own recursive mutex using only traditional mutexes. I think this solution could work: variables: m, critSect: mutex; lockCount: int; owner: thread ID; lock() implementation: critSect.lock() if ( owner == 0 ) // mutex is not owned by anyone... It's not portable to compare a pthread_t against zero, nor to assume that zero cannot be a valid thread ID. On some operating systems, pthread_t is in an integer, and the main thread is assigned the value zero. On some others, pthread_t is a struct. This is easy to fix by using an extra flag to indicate that the mutex is not owned. { ++lockCount; owner = pthread_self(); m.lock(); This is a problem; while a thread waits here on mutex m, it is holding mutex critSect. So no other thread can perform any operation on the lock, including the thread which owns the mutex m. } else if ( owner == pthread_self() ) // I already have this mutex! ++lockCount; else // someone locks this mutex! { critSect.unlock(); m.lock(); critSect.lock(); lockCount = 1; Also, you have a horrible race here that leads to deadlock situation, because you acquire the locks in an opposite order. Suppose that just after you call m.lock() some other thread calls this function. That other thread acquires critSect.lock(), sees that there is not yet any owner, and so calls m.lock(). However, your thread has already acquired the lock m, so that other thread has to wait. Meanwhile, your thread calls critSect.lock() and the deadly embrace is complete. I believe that the problem can be solved like this: void lock::acquire() { crit_sect.lock(); bool i_am_the_owner = is_locked owner == pthread_self(); crit_sect.unlock(); if (i_am_the_owner) lock_count++; else { m.lock(); crit_sect.lock(); is_locked = true; owner = pthread_self(); crit_sect.unlock(); } } void lock::release() { if (--lock_count == 0) { crit_sect.lock(); is_locked = false; crit_sect.unlock(); m.unlock(); } } Note that only the lock_count is protected by m. Only the flag is_locked and the owner variable are protected by crit_sect. The two times when both locks are held by the caller are in the else clause in lock::acquire, and in the body of the if in ::release. There is no opposite locking m is always acquired first, hence no risk of deadlock. Final remark: you'd be better off working with non-recursive locks. Recursive locks are error prone. -- From: "Gene Soudlenkov" [EMAIL PROTECTED] Subject: Re: reliable coredump under Linux? Date: Wed, 7 Feb 2001 13:38:17 +1300 Hi, We've got the same problem with our application. Could you give a clue what changes have been done in binfmt_elf? Gene rachel braverman [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... We face a problem after patching the kernel. Maybe you have an idea what we need to do: We run a multithreaded application (it happens for any multithreaded applications) using our compiled 2.2.17 kernel with glibc-2.1.2-11. When we send a kill -SEGV thread pid When analyzing the core dump we see that it has the information of only the dumping thread which is not the same threads that received the signal (it is the last thread which goes down). To fix that we changed the following files: fs/binfmt_elf.c kernel/fork.c include/linux/sched.h This fix pr
Linux-Development-Sys Digest #471
Linux-Development-Sys Digest #471, Volume #6 Thu, 11 Mar 99 16:14:07 EST Contents: ANNOUNCE: Kernel Traffic #9 is out ([EMAIL PROTECTED]) A question about Voodoo Banshee on Linux ("David Kim") Re: Driver Programming (Duane Elmer Smeckert) Re: Threads and clone() (Kelly Burkhart) Re: Remote kernel debugger for x86 Linux (Josef =?iso-8859-1?Q?M=F6llers?=) undefined reference ("asdf") who problems ("asdf") Re: who problems (Rick Lim) Q: Linux as FAX server for SAP R/3? (Ulrich Windl) madvise (part of mman.h) ("David Bower") Build err glibc-2.0.7pre6 (Tom Daley) Re: Q: Linux as FAX server for SAP R/3? (Fritz Schadt) Re: Remote kernel debugger for x86 Linux (Alan McLean) MaxFileSize ("Timur A. Isaev") Re: Gnome does not start !! Help !! ([EMAIL PROTECTED]) Re: Linux Dell PC (Sam Steingold) Newbie Q about Linux Programming (Mark Bratcher) code page and locale questions (normski_r) Linux Dell PC (Ramesh Kumar) Re: madvise (part of mman.h) ("Gerry S. Hayes") Re: module coding how-to needed (Przemek Klosowski) Re: A question about Voodoo Banshee on Linux (Michael Wm. Gilbert) Re: Linux programming jobs? (Roope Anttinen) From: [EMAIL PROTECTED] Crossposted-To: comp.os.linux.misc Subject: ANNOUNCE: Kernel Traffic #9 is out Date: Thu, 11 Mar 1999 08:06:08 GMT Check out this week's Kernel Traffic at http://www.kt.opensrc.org = Posted via Deja News, The Discussion Network http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own -- From: "David Kim" [EMAIL PROTECTED] Subject: A question about Voodoo Banshee on Linux Date: Thu, 11 Mar 1999 00:05:54 -0800 I've recently purchased Monster Fusion which runs on Voodoo Banshee chip set. When I try to install RedHat Linux 5.2 on my computer, the installation wizard won't recognize the video card. Of course, I kind of knew that my video card wouldn't be on the video card configuration wizard list since it's a very new video card. Can somebody help me how to configure this video card? I would greatly appreciate if someone can help me out. -- Date: Thu, 11 Mar 1999 00:59:31 -0800 From: Duane Elmer Smeckert "elmer at"@ ptw dot. com Crossposted-To: comp.os.linux.development,comp.os.linux.questions Subject: Re: Driver Programming Just a little rant to newbies; Don't ask us to email you answers.The whole idea here is that you should help those behind you as those ahead of you help you. I don't expect my guru to live here, so to seek his favor I answer the newer easy questions, leaving him to answer mine. If you don't want to play, fine. If you want to lurk, fine. But don't think this is something for nothing, this is community! "snurf" [EMAIL PROTECTED] was on about something like: Thanks to answer to: [EMAIL PROTECTED] -- Subject: Re: Threads and clone() From: Kelly Burkhart [EMAIL PROTECTED] Date: 10 Mar 1999 21:51:15 -0600 Bernd Potzkai [EMAIL PROTECTED] writes: Hi, I am trying to port some OS/2 and windows apps to Linux. However using of clone() is failing, because the function was not found by the linker. In which library exists clone() or is something else wrong ? Where do I find more information (books, howtos, etc.) about multithreading under Linux ? The linux distribution that I use is SuSE 6.0. Thanks, Bernd If your distribution uses glibc, you should use pthreads. Pthreads in recent glibc evolved from LinuxThreads written by Xavier Leroy. The threading is implemented using clone(). FWIW, to use clone directly you must use assembler. -- Kelly R. Burkhart [EMAIL PROTECTED] -- From: Josef =?iso-8859-1?Q?M=F6llers?= [EMAIL PROTECTED] Subject: Re: Remote kernel debugger for x86 Linux Date: Thu, 11 Mar 1999 09:38:33 +0100 accoday wrote: hello, 'been reading "Linux Device Drivers" where he mentioned that to his knowledge they are no remote kernel debuggers for the x86 platform. Does anybody know of any now? There is a mode in gdb that allows remote debugging (of cooperating user programs). The stub that needs to be compiled into the user program can also be adapter to run in the kernel. I'll be having a go at it when CeBIT is over ... Josef -- Reply-To: "asdf" [EMAIL PROTECTED] From: "asdf" [EMAIL PROTECTED] Subject: undefined reference Date: Thu, 11 Mar 1999 03:38:38 -0800 i get an "undefined reference to crypt" when compiling the ppp-2.3.5 package. how can i fix this? i have egcs-1.1.1 and glibc-2.1 installed. -- Reply-To: "asdf" [EMAIL PROTECTED] From: "asdf" [EMAIL PROTECTED] Subject: who problems Date: Thu,