WIKI AllocSysObject ASO_NoTrack clarification

Have a question about our Software Developer Kit? Ask them here.

WIKI AllocSysObject ASO_NoTrack clarification

Postby xenic » Sun Nov 23, 2014 9:32 pm

The autodoc for AllocSysObject says this about the ASO_NoTrack option:

    ASO_NoTrack: A boolean value that indicates
    whether the object should be tracked or not.

    This might be useful for stuff that is dangrous
    to get rid of automatically, like semaphores.
    Also, tracking has a slight additional memory overhead.
    Default: TRUE (i.e do not track)

That explanation is a little ambiguous to me. Is it useful to track or not track for things that are dangerous to get rid of automatically? Does this mean that selecting ASO_NoTrack TRUE would mean that memory allocated for the name of a semaphore that is copied by ASOT_SEMAPHORE ASOSYM_Copyname will not be tracked and freed automatically when FreeSysObject() is called? Also, why is it dangerous to get rid of a semaphore automatically?
AmigaOne X1000 with 2GB memory - OS4.1 FE
xenic
 
Posts: 1160
Joined: Sun Jun 19, 2011 1:06 am

Re: WIKI AllocSysObject ASO_NoTrack clarification

Postby Hans » Mon Nov 24, 2014 5:28 am

@xenic

FreeSysObject() will always fully free an object (incl. memory). Tracking enables objects to be automatically cleaned up when a task/process ends. I assume that tracked objects are also automatically cleaned up after a task has been terminated due to crashing, but I'm not 100% sure.

Since semaphores are used for synchronization between multiple tasks, automatically freeing it when the task that created it stops could be risky. Other tasks that use that semaphore might try to access it after it's been freed.

I see tracking as a backup for when things go wrong, and believe that software should still manually free all objects before exiting. Not doing so is kind of lazy.

Hans
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. Home of the RadeonHD driver for Amiga OS 4.x project.
User avatar
Hans
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 703
Joined: Tue Dec 21, 2010 10:25 pm
Location: New Zealand


Return to SDK Support

Who is online

Users browsing this forum: No registered users and 1 guest