Is malloc reentrant

Joerg Lehners lehners at uniol.uucp
Sun Jul 1 18:04:00 AEST 1990


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 at uniol              | Joerg Lehners                  \
|       ...!uunet!unido!uniol!lehners | Fachbereich 10 Informatik ARBI |
| BITNET:  066065 AT DOLUNI1          | Universitaet Oldenburg         |
\ Inhouse: aragorn!joerg              | D-2900 Oldenburg               /



More information about the Comp.sys.sun mailing list