[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] xmalloc, thread-safety
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] xmalloc, thread-safety |
Date: |
Thu, 30 Aug 2007 11:27:18 +0400 |
> I am trying to run GLPK in multi-thread way, but I discovered, that
> there is a problem with memory allocation/deallocation.
> As I know, standard malloc and free should be thread-safe. Is there
> any special reason why you implement some higher "protocol" using
> xmalloc/xfree?
Mainly for internal needs (for example, to check that no allocated
blocks are lost, etc.).
> I modified the library code:
> void *xmalloc(int size) {
> return calloc(1, size);
> ....
> }
> ( xfree similarly) and my testing program works fine,
To make glpk thread-safe you need to provide two platform-specific
routines lib_set_ptr and lib_get_ptr (see src/glplib03.c). By default
these routines store a pointer in the static memory, and currently
only a version for the windows dll is implemented.
> but malloc takes to
> much processor time. There are many "xcalloc" in "simplex1"
> function. Is it possible to pack them all to only one xcalloc call
> with offsets?
I do not think that that would resolve the problem.
Andrew Makhorin