From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,2c710271be0eb4ac X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-12-20 18:40:01 PST Newsgroups: comp.unix.osf.osf1 Path: nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!gatech!newsxfer.itd.umich.edu!zip.eecs.umich.edu!caen!crl.dec.com!crl.dec.com!decvax.dec.com!denham From: denham@denham.zk3.dec.com (Jeffrey M. Denham) Subject: Re: pthread problem Message-ID: <1994Dec20.231424.29230@decvax.dec.com> Sender: usenet@decvax.dec.com (Usenet News System) Nntp-Posting-Host: denham.zk3.dec.com Reply-To: denham@zk3.dec.com (Jeffrey M. Denham) Organization: Digital Equipment Corporation X-Newsreader: mxrn 6.18-5 References: <3d3uqp$dvk@lyra.csx.cam.ac.uk> Date: Tue, 20 Dec 1994 23:14:24 GMT In article <3d3uqp$dvk@lyra.csx.cam.ac.uk>, rnw@cam-orl.co.uk (Rob Walker) writes: |> |>Can anyone provide an explanation (& preferably a fix) for the |>behaviour exhibited by the following short pthreads program. |> |>When it is compiled using: |>gcc -o spin spin.c -lc_r -lpthreads -lmach |> |>and run it burns up all the available CPU (according to top) |>but the time it uses never increases -> it is very busy in the |>kernel. Since both threads are blocked surely the process should |>be idle. |> |>In the application where this was causing a problem one thread |>was blocked on a mutex and the other on a 'select' call. But |>the behaviour was the same as shown by the code below. |> |>This happens with OSF/1 V2.0 (Rev 240) - I'd very much like to |>hear if it occurs on a newer release (which I don't have access |>to). |> |>(If there is a more appropriate newsgroup for this query then |>please point me at it. The pthreads library code is doing a "semi" busy wait on the mutex. This does not occur on V3.0. BTW, the correct link order of the libraries is -lpthreads -lmach -lc_r In V2.0 and later cc, -threads switch does this for you.