since I got interested: here's an example of using 
__attribute__((cleanup(variable))) in HAL locking

http://git.mah.priv.at/gitweb/emc2-dev.git/commit/e121c0fb82f8ea408b9d3ddbb1eb6189e9caed4d

-m

Am 20.07.2012 um 08:49 schrieb Michael Haberler:

> 
> Am 20.07.2012 um 08:06 schrieb Philippe Frossard:
> 
>> Hi,
>> We are writting a little application in C inspired from different sources,
>> We are create an Hal structure with hal_malloc,
>> I would like to know if I need to use hal_set_lock or hal_get_lock to 
>> access this structure ?
>> or if I can access this structure directly ...
>> 
>> I see also in hal_lib.c and rtai.h the functions rtapi_mutex_get and 
>> rtapi_mutex_give ...
> 
> The way I understand it you need to lock the namestore when looking up, or 
> inserting new pins/signals/params  etc so the linked lists in the global HAL 
> namespace remain consistent (in case separate components happened to lookup 
> and insert, or insert/insert HAL objects concurrently). 
> 
> Make sure you release the lock regardless of the path taken out of the code 
> which aquires the lock or pain will result, see for instance 
> src/hal/utils/halcmd_commands.c:do_setp_command .
> 
> A more elegant way to unlock the haldata mutex would be to use a cleanup 
> variable attribute which triggers a function call when the variable goes out 
> of scope; see http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html
> 
> - Michael
> 
>> 
>> Thanks.
>> 
>> -- 
>> Philippe Frossard
>> 
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and 
>> threat landscape has changed and how IT managers can respond. Discussions 
>> will include endpoint security, mobile security and the latest in malware 
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Emc-developers mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/emc-developers
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Emc-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-developers


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to