MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_dm_ida_take

Function rt_dm_ida_take

components/drivers/core/dm.c:96–115  ·  view source on GitHub ↗

* @brief This function will take (force) an id in an IDA object * * @param ida is the IDA object * * @param id is the id that want to take * * @return the result of taking */

Source from the content-addressed store, hash-verified

94 * @return the result of taking
95 */
96rt_bool_t rt_dm_ida_take(struct rt_dm_ida *ida, int id)
97{
98 RT_ASSERT(ida != RT_NULL);
99 RT_ASSERT(id >= 0);
100
101 rt_spin_lock(&ida->lock);
102
103 if (!rt_bitmap_test_bit(ida->map, id))
104 {
105 rt_bitmap_set_bit(ida->map, id);
106 }
107 else
108 {
109 id = RT_DM_IDA_NUM;
110 }
111
112 rt_spin_unlock(&ida->lock);
113
114 return id != RT_DM_IDA_NUM;
115}
116
117/**
118 * @brief This function will release an id in an IDA object

Callers

nothing calls this directly

Calls 4

rt_bitmap_test_bitFunction · 0.85
rt_bitmap_set_bitFunction · 0.85
rt_spin_lockFunction · 0.50
rt_spin_unlockFunction · 0.50

Tested by

no test coverage detected