Click Here
home features news forums classifieds faqs links search
6155 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
» Home
» Features
» News
» Forums
» Classifieds
» Links
» Downloads
Extras
» OS4 Zone
» IRC Network
» AmigaWorld Radio
» Newsfeed
» Top Members
» Amiga Dealers
Information
» About Us
» FAQs
» Advertise
» Polls
» Terms of Service
» Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
22 crawler(s) on-line.
 95 guest(s) on-line.
 0 member(s) on-line.



You are an anonymous user.
Register Now!

/  Forum Index
   /  Amiga Development
      /  AllocPooled() threadsafe?
Register To Post

PosterThread
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
Profile     Report this post  
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
Profile     Report this post  
NutsAboutAmiga 
Re: AllocPooled() threadsafe?
Posted on 27-Mar-2013 11:46:36
#3 ]
Elite Member
Joined: 9-Jun-2004
Posts: 13047
From: Norway

@Wanderer

The trick whit all asynchronous applications is to make shore all processes/tasks/threads are done whit the memory / picture / lists, before you free or change it.

MutexObtain(mem_mutex) is useful for this.

http://wiki.amigaos.net/index.php/Exec_Mutexes

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
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
Profile     Report this post  
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
Profile     Report this post  

[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle