# Is the ZCL library thread safe?

**URL:** <https://forums.digi.com/t/is-the-zcl-library-thread-safe/14746>\
**Category:** XBee Programamble (S2C & 900 HP)\
**Tags:** programmable, zdo, zcl, xbee\
**Created:** [April 22, 2015, 8:40pm UTC](https://forums.digi.com/t/is-the-zcl-library-thread-safe/14746 "2015-04-22T20:40:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wz2b](https://avatars.discourse-cdn.com/v4/letter/w/e274bd/32.png) [@wz2b](https://forums.digi.com/u/wz2b)\
**Post date:** [April 22, 2015, 8:40pm UTC](https://forums.digi.com/t/is-the-zcl-library-thread-safe/14746/1 "2015-04-22T20:40:33Z")

</div>

Is the XBee Programmable built-in ZDO/ZCL support thread-safe? Specifically if you define an attribute in

```auto

// in zcl_attribute_base_t:
/// Pointer to global variable of correct type, set as \c const to allow
/// for both const and non-const values. (If \c const, flags should be
/// include #ZCL_ATTRIB_FLAG_READONLY.) If NULL, the ZCL stack will
/// respond to attempts to read/write with ZCL_STATUS_DEFINED_OUT_OF_BAND.
	const void FAR	*value;

```

I’m asking in the event that the attribute is say 32 bits. What do I need to do to ensure that it’s returned atomically?

One specific example I have is a 32-bit event counter. It can incremented from my foreground (main state machine) or from a GPIO interrupt. When I access it from the foreground state machine I turn some interrupts off first. What I don’t really understand (and the root of this question) is interaction and thread safety issues within the ZDO/ZCL code e.g. the “general” handler.

–Chris

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [September 14, 2015, 4:29pm UTC](https://forums.digi.com/t/is-the-zcl-library-thread-safe/14746/2 "2015-09-14T16:29:38Z")

</div>

Chris, the ZDO and ZCL stand for Zigbee Device Object and Zigbee Cluster Library. Both of which correspond to the Zigbee standards.

The 32 bits it is referring to are the specific ZDO and ZCL items your application needs to support. It is not referring to a solid state setting.
