task_id_t task_get(unsigned char block)
{
- task_id_t t = 0;
+ task_id_t t = -1;
unsigned long ids;
do {
ids = _task_ids;
nei();
if (ids) {
- for (unsigned char i = 0; t == 0 && i < TASK_COUNT; i++) {
- if (ids & (1UL << _task_bitno))
+ for (unsigned char i = 0; t == -1 && i < TASK_COUNT; i++) {
+ if (bit_get(ids, _task_bitno))
t = _task_bitno;
_task_bitno = (_task_bitno + 1) % TASK_COUNT;
}
else
SLEEP();
#endif
- } while (t == 0 && block == 1);
+ } while (t == -1 && block == 1);
+ if (t) {
+ ndi();
+ bit_clr(_task_ids, t);
+ nei();
+ }
return t;
}
-void task_post(task_id_t t)
-{
- ndi();
- _task_post(t);
- nei();
-}
-