Path: utzoo!attcan!uunet!wuarchive!cs.utexas.edu!rice!sun-spots-request From: lehners@uniol.uucp (Joerg Lehners) Newsgroups: comp.sys.sun Subject: Re: Is malloc reentrant Keywords: SunOS Message-ID: <9547@brazos.Rice.edu> Date: 1 Jul 90 08:04:00 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 20 Approved: Sun-Spots@rice.edu X-Refs: Original: v9n245 X-Sun-Spots-Digest: Volume 9, Issue 245, message 7 In comp.sys.sun you write: >Is malloc guaranteed to be reentrant, if not is it reentrant on any >systems? I think malloc can't be reentrant because it modifies a global resource (the heap). I cannot imagine an algorithmn that modifies a global resource without using some kind of locking. Implementing malloc (and friends free, realloc, calloc) with a locking mechanismn is useless in single threaded application: another call to malloc from e.g. a signal handler would block the whole application, if the signal handler was called when the process was in the middle of malloc. Whereas malloc with a locking mechanism would be sensefull in mutli threaded applications (like the light weight prcess of SunOS4.x) Joerg Lehners / UUCP: lehners@uniol | Joerg Lehners \ | ...!uunet!unido!uniol!lehners | Fachbereich 10 Informatik ARBI | | BITNET: 066065 AT DOLUNI1 | Universitaet Oldenburg | \ Inhouse: aragorn!joerg | D-2900 Oldenburg /