Counting semaphore with task notifications behaviour


I want to use a counting semaphore using direct to task notifications in this scenario:

I have a counting process and I want to be notified (the receiver task is woken up) every n items exactly and exclusively, I don’t want to be notified every item (the receiver task is is woken up whenever a single item is detected).

The examples given here, as far as I understood (or I misunderstood) count on every single item, so the system doesn’t miss any of them.

Is there a way to be notified only when exactly n items were detected using direct to task notifications, or do I need to use the semaphore primitives instead?

Thank you!

Yes, counting semaphores wake up for every signal, the counting allows them to ‘fall behind’ and catch up.

I would say that for your system, somebody needs to count off the every N and only signal when that. is satisfied.