cb_wait_front
-
void cb_wait_front(int32_t operand, int32_t num_pages)
-
A blocking call that waits for the specified number of tiles to be available in the specified circular buffer (CB). This call is used by the consumer of the CB to wait for the producer to fill the CB with at least the specified number of tiles. Important note: in case multiple calls of cb_wait_front(n) are issued without a paired cb_pop_front() call, n is expected to be incremented by the user to be equal to a cumulative total of tiles. Example: 4 calls of cb_wait_front(8) followed by a cb_pop_front(32) would produce incorrect behavior. Instead 4 calls of cb_wait_front() waiting on 8, 16, 24, 32 tiles should be issued.
Important note: the total number of tiles passed to cb_pop_front/cb_push_back calls within one complete cycle of the CB must sum to exactly the CB size (fifo_num_pages) so that the internal pointer wraps correctly. Individual pop or push amounts do not need to evenly divide the CB size. Example: on a CB of size 12, cb_pop_front(5) followed by cb_pop_front(7) is correct (total 12 = CB size). However, cb_pop_front(7) followed by cb_pop_front(7) on the same CB is incorrect (total 14 != 12). Out-of-bounds pointer advancement is detected at runtime when watcher or lightweight kernel asserts are enabled.
Return value: None
Argument
Description
Type
Valid Range
Required
cb_id
The index of the circular buffer (CB)
uint32_t
0 to 31
True
num_tiles
The number of tiles to wait for
uint32_t
It must be less or equal than the size of the CB (the total number of tiles that fit into the CB)