Environment variables WIP, fix waiting scheduling issues + CE cancel proc
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m24s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m24s
This commit is contained in:
@@ -31,14 +31,20 @@ int id_alloc (struct id_alloc* ida) {
|
||||
|
||||
spin_lock (&ida->lock, &fid);
|
||||
|
||||
for (size_t bit = 0; bit < ida->bm.nbits; bit++) {
|
||||
if (!bm_test (&ida->bm, bit)) {
|
||||
bm_set (&ida->bm, bit);
|
||||
size_t start = ida->next_id;
|
||||
size_t current = start;
|
||||
do {
|
||||
if (!bm_test (&ida->bm, current)) {
|
||||
bm_set (&ida->bm, current);
|
||||
|
||||
ida->next_id = (current + 1) % ida->bm.nbits;
|
||||
|
||||
spin_unlock (&ida->lock, fid);
|
||||
return (int)bit;
|
||||
return (int)current;
|
||||
}
|
||||
}
|
||||
|
||||
current = (current + 1) % ida->bm.nbits;
|
||||
} while (current != start);
|
||||
|
||||
spin_unlock (&ida->lock, fid);
|
||||
return -ST_OOM_ERROR;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
struct id_alloc {
|
||||
struct bm bm;
|
||||
spin_lock_t lock;
|
||||
int next_id;
|
||||
};
|
||||
|
||||
int id_alloc (struct id_alloc* ida);
|
||||
|
||||
Reference in New Issue
Block a user