Also in your patch, thread should exit only after scheduler returns EVENT_INVALID. Since the cool_down event is the last event on all queues (as they are enqueued after all threads have passed the barrier), when we have received all cool_down events we know that there are no other events on the these queues. No need to call odp_schedule() until it returns ODP_EVENT_INVALID (which can happen spuriously anyway so doesn't signify anything).
It signifies release of the schedule context. For a robust exit, application should release the current context. -Petri