Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
|
|
|
22 crawler(s) on-line.
95 guest(s) on-line.
0 member(s) on-line.
You are an anonymous user. Register Now! |
|
|
|
| Poster | Thread | Wanderer
|  |
AllocPooled() threadsafe? Posted on 27-Mar-2013 9:26:09
| | [ #1 ] |
| |
 |
Cult Member  |
Joined: 16-Aug-2008 Posts: 654
From: Germany | | |
|
| Hi All!
Does anyone know what restrictions apply to Alloc/FreePooled() ?
My problem is, that I allocate some memory with AllocPooled in two different threads (actually AmigaOS "Process"es) on the same pool. Which ends up occasionally in a disaster. My question is, if I am doing something logically wrong or is AllocPooled not threadsafe and the Pool-Bookkeeping is screwed up. I couldnt find anything in the RKM about this.
What about AllocVec? I quickly replaced my Alloc/FreePooled with Alloc/FreeVec, but still have memory corruption issues.
Last edited by Wanderer on 27-Mar-2013 at 09:26 AM.
_________________ -- Author of HD-Rec, Sweeper, Samplemanager, ArTKanoid, Monkeyscript, Toadies, AsteroidsTR, TuiTED, PosTED, TKPlayer, AudioConverter, ScreenCam, PerlinFX, MapEdit, AB3 Includes and many more... Homepage: http://www.hd-rec.de |
| | Status: Offline |
| | tboeckel
|  |
Re: AllocPooled() threadsafe? Posted on 27-Mar-2013 10:03:43
| | [ #2 ] |
| |
 |
Regular Member  |
Joined: 7-Oct-2004 Posts: 274
From: Rehmerloh, Germany | | |
|
| @Wanderer
Quote:
| Does anyone know what restrictions apply to Alloc/FreePooled() ? |
By default memory pools are NOT thread safe. Thread safety must be enabled explicitly. Unfortunately this is done in a different fashion on all the systems.
For AmigaOS4 you must create the memory pool using AllocSysObject() and must set ASOPOOL_Protected to TRUE. For MorphOS and AROS you must add MEMF_SEM_PROTECTED to the memory flags for the CreatePool() call. For AmigaOS3 there is no arbitration at all and you must create your own semaphore and obtain/release it for each allocation.
Quote:
| What about AllocVec? I quickly replaced my Alloc/FreePooled with Alloc/FreeVec, but still have memory corruption issues. |
AllocVec() definitely is thread safe, otherwise the system would not be able to boot or run at all. If you are experiencing trashed memory, then most probably your code is causing buffer overruns/underruns, accesses invalid pointers or even recently freed memory._________________ Why stop it now, just when I am hating it?
Thore Böckelmann |
| | Status: Offline |
| | NutsAboutAmiga
|  |
Re: AllocPooled() threadsafe? Posted on 27-Mar-2013 11:46:36
| | [ #3 ] |
| |
 |
Elite Member  |
Joined: 9-Jun-2004 Posts: 13047
From: Norway | | |
|
| | | Status: Offline |
| | Wanderer
|  |
Re: AllocPooled() threadsafe? Posted on 27-Mar-2013 12:47:56
| | [ #4 ] |
| |
 |
Cult Member  |
Joined: 16-Aug-2008 Posts: 654
From: Germany | | |
|
| @tboeckel
Thanks, I think this answers my question. _________________ -- Author of HD-Rec, Sweeper, Samplemanager, ArTKanoid, Monkeyscript, Toadies, AsteroidsTR, TuiTED, PosTED, TKPlayer, AudioConverter, ScreenCam, PerlinFX, MapEdit, AB3 Includes and many more... Homepage: http://www.hd-rec.de |
| | Status: Offline |
| | itix
|  |
Re: AllocPooled() threadsafe? Posted on 27-Mar-2013 17:58:53
| | [ #5 ] |
| |
 |
Elite Member  |
Joined: 22-Dec-2004 Posts: 3398
From: Freedom world | | |
|
| @Wanderer
AllocMem() (and therefore AllocVec(), too) is of course thread safe because it is system global memory allocation function shared across different processes simultaneously.
If you are having memory corruption issues you should use Wipeout to catch buffer under/overflow bugs. It also helps to catch invalid pointers or access to freed memory.
Last edited by itix on 27-Mar-2013 at 06:00 PM.
_________________ Amiga Developer Amiga 500, Efika, Mac Mini and PowerBook |
| | Status: Offline |
| |
|
|
|
[ home ][ about us ][ privacy ]
[ forums ][ classifieds ]
[ links ][ news archive ]
[ link to us ][ user account ]
|