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

Function rid_bitmap_get_named

components/utilities/resource/rid_bitmap.c:54–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54long rid_bitmap_get_named(rid_bitmap_t mgr, long no)
55{
56 long id_relative;
57 long overflow;
58 long min;
59
60 if (mgr->id_lock)
61 {
62 rt_mutex_take(mgr->id_lock, RT_WAITING_FOREVER);
63 }
64
65 min = mgr->min_id;
66 id_relative = no - min;
67 overflow = mgr->total_id_count;
68 if (id_relative >= min && id_relative < overflow)
69 {
70 if (rt_bitmap_test_bit(mgr->bitset, id_relative))
71 {
72 id_relative = -RT_EBUSY;
73 }
74 else
75 {
76 rt_bitmap_set_bit(mgr->bitset, id_relative);
77 id_relative += min;
78 }
79 }
80 else
81 {
82 id_relative = -1;
83 }
84
85 if (mgr->id_lock)
86 {
87 rt_mutex_release(mgr->id_lock);
88 }
89 return id_relative;
90}
91
92void rid_bitmap_put(rid_bitmap_t mgr, long no)
93{

Callers

nothing calls this directly

Calls 4

rt_mutex_takeFunction · 0.85
rt_bitmap_test_bitFunction · 0.85
rt_bitmap_set_bitFunction · 0.85
rt_mutex_releaseFunction · 0.85

Tested by

no test coverage detected