Finding the next in round-robin scheduling by bit twiddling
Consider the following problem. You have a bit-string that represents the current scheduled slave in one-hot encoding. For example, "00000100" (with the leftmost bit being #7 and rightmost #0) means that slave #2 is scheduled. Now, I want to pick the next scheduled slave in a round-robin scheduling scheme, with a twist. I have a "request mask" which says which slaves actually want to be scheduled. The next slave will be picked only from those that want to. Some examples (assume round-robin scheduling is done by rotating left). Example1: Current: "00000100" Mask: "01100000" Next schedule: